summaryrefslogtreecommitdiff
path: root/src/_pytest/pathlib.py
diff options
context:
space:
mode:
authorBruno Oliveira <nicoddemus@gmail.com>2019-05-27 20:31:52 -0300
committerBruno Oliveira <nicoddemus@gmail.com>2019-06-02 14:39:11 -0300
commit4d49ba65297102110ae8aeecdb3b82b23a231fba (patch)
tree10a917331db131a6728775ff7d462732ff1f9466 /src/_pytest/pathlib.py
parent733f43b02eafe2934c2e86b7d0370e25dfe95a48 (diff)
downloadpytest-4d49ba65297102110ae8aeecdb3b82b23a231fba.tar.gz
Drop Python 2.7 and 3.4 support
* Update setup.py requires and classifiers * Drop Python 2.7 and 3.4 from CI * Update docs dropping 2.7 and 3.4 support * Fix mock imports and remove tests related to pypi's mock module * Add py27 and 34 support docs to the sidebar * Remove usage of six from tmpdir * Remove six.PY* code blocks * Remove sys.version_info related code * Cleanup compat * Remove obsolete safe_str * Remove obsolete __unicode__ methods * Remove compat.PY35 and compat.PY36: not really needed anymore * Remove unused UNICODE_TYPES * Remove Jython specific code * Remove some Python 2 references from docs Related to #5275
Diffstat (limited to 'src/_pytest/pathlib.py')
-rw-r--r--src/_pytest/pathlib.py19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py
index 729c41797..2cd931b32 100644
--- a/src/_pytest/pathlib.py
+++ b/src/_pytest/pathlib.py
@@ -8,7 +8,6 @@ import os
import shutil
import sys
import uuid
-from functools import reduce
from os.path import expanduser
from os.path import expandvars
from os.path import isabs
@@ -18,9 +17,8 @@ from posixpath import sep as posix_sep
import six
from six.moves import map
-from .compat import PY36
-if PY36:
+if sys.version_info[:2] >= (3, 6):
from pathlib import Path, PurePath
else:
from pathlib2 import Path, PurePath
@@ -84,17 +82,6 @@ def parse_num(maybe_num):
return -1
-if six.PY2:
-
- def _max(iterable, default):
- """needed due to python2.7 lacking the default argument for max"""
- return reduce(max, iterable, default)
-
-
-else:
- _max = max
-
-
def _force_symlink(root, target, link_to):
"""helper to create the current symlink
@@ -119,7 +106,7 @@ def make_numbered_dir(root, prefix):
"""create a directory with an increased number as suffix for the given prefix"""
for i in range(10):
# try up to 10 times to create the folder
- max_existing = _max(map(parse_num, find_suffixes(root, prefix)), default=-1)
+ max_existing = max(map(parse_num, find_suffixes(root, prefix)), default=-1)
new_number = max_existing + 1
new_path = root.joinpath("{}{}".format(prefix, new_number))
try:
@@ -230,7 +217,7 @@ def try_cleanup(path, consider_lock_dead_if_created_before):
def cleanup_candidates(root, prefix, keep):
"""lists candidates for numbered directories to be removed - follows py.path"""
- max_existing = _max(map(parse_num, find_suffixes(root, prefix)), default=-1)
+ max_existing = max(map(parse_num, find_suffixes(root, prefix)), default=-1)
max_delete = max_existing - keep
paths = find_prefixed(root, prefix)
paths, paths2 = itertools.tee(paths)