From 2e39fd89d1f54d924c10094659254e7c66096e0a Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Sun, 16 Sep 2018 14:34:50 +0200 Subject: [PATCH] add python27 support by using reduce instead of max --- src/_pytest/tmpdir.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/_pytest/tmpdir.py b/src/_pytest/tmpdir.py index f1d52d497..bf4e9e6b0 100644 --- a/src/_pytest/tmpdir.py +++ b/src/_pytest/tmpdir.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, division, print_function import re +from six.moves import reduce import pytest import py @@ -24,13 +25,14 @@ def make_numbered_dir(root, prefix): for i in range(10): # try up to 10 times to create the folder - max_existing = max( + max_existing = reduce( + max, ( parse_num(x) for x in root.iterdir() if x.name.lower().startswith(l_prefix) ), - default=-1, + -1, ) new_number = max_existing + 1 new_path = root.joinpath("{}{}".format(prefix, new_number))