From abbf73ad1a3b5d8d4522df2ca2d3f0c83ea8e349 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Tue, 19 Jun 2018 19:45:20 +0200 Subject: [PATCH] use pathlib2 up to python3.4 - damn the stdlib --- setup.py | 6 ++++-- src/_pytest/compat.py | 9 ++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index ed5a96d5e..710228658 100644 --- a/setup.py +++ b/setup.py @@ -73,16 +73,18 @@ def main(): environment_marker_support_level = get_environment_marker_support_level() if environment_marker_support_level >= 2: install_requires.append('funcsigs;python_version<"3.0"') - install_requires.append('pathlib2;python_version<"3.0"') + install_requires.append('pathlib2;python_version<"3.5"') install_requires.append('colorama;sys_platform=="win32"') elif environment_marker_support_level == 1: - extras_require[':python_version<"3.0"'] = ["funcsigs", "pathlib2"] + extras_require[':python_version<"3.0"'] = ["funcsigs"] + extras_require[':python_version<"3.5"'] = ["pathlib2"] extras_require[':sys_platform=="win32"'] = ["colorama"] else: if sys.platform == "win32": install_requires.append("colorama") if sys.version_info < (3, 0): install_requires.append("funcsigs") + if sys.version_info < (3, 5): install_requires.append("pathlib2") setup( diff --git a/src/_pytest/compat.py b/src/_pytest/compat.py index ec647bb44..01d46222d 100644 --- a/src/_pytest/compat.py +++ b/src/_pytest/compat.py @@ -30,11 +30,8 @@ _PY2 = not _PY3 if _PY3: from inspect import signature, Parameter as Parameter - from pathlib import Path else: from funcsigs import signature, Parameter as Parameter - from pathlib2 import Path - NoneType = type(None) NOTSET = object() @@ -43,6 +40,12 @@ PY35 = sys.version_info[:2] >= (3, 5) PY36 = sys.version_info[:2] >= (3, 6) MODULE_NOT_FOUND_ERROR = "ModuleNotFoundError" if PY36 else "ImportError" +if PY35: + from pathlib import Path +else: + from pathlib2 import Path + + if _PY3: from collections.abc import MutableMapping as MappingMixin # noqa from collections.abc import Mapping, Sequence # noqa