Skip to content

Commit 43ff7bb

Browse files
adamchainzblueyed
authored andcommitted
Use pathlib2 (#636)
The dependency on `pathlib` was added in #631. A backport is needed for Python <3.4. The `pathlib` package [on PyPI](https://pypi.org/project/pathlib/) is maintenance-only and comes with a message about using `pathlib2` for an up-to-date version, still importable as `pathlib`. Also `pytest` itself uses `pathlib2` so currently I'm getting both packages installed, one on top of the other, woops! This change in `setup.py` seems to be all that's needed to switch.
1 parent 5619f16 commit 43ff7bb

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

pytest_django/plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import sys
1212
import types
1313

14-
import pathlib
1514
import pytest
1615

1716
from .django_compat import is_django_unittest # noqa
@@ -38,6 +37,11 @@
3837

3938
from .lazy_django import django_settings_is_configured, skip_if_no_django
4039

40+
try:
41+
import pathlib
42+
except ImportError:
43+
import pathlib2 as pathlib
44+
4145

4246
SETTINGS_MODULE_ENV = 'DJANGO_SETTINGS_MODULE'
4347
CONFIGURATION_ENV = 'DJANGO_CONFIGURATION'

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def read(fname):
3232
setup_requires=['setuptools_scm>=1.11.1'],
3333
install_requires=[
3434
'pytest>=3.6',
35-
'pathlib;python_version<"3.4"',
35+
'pathlib2;python_version<"3.4"',
3636
],
3737
extras_require={
3838
'docs': [

tests/conftest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
import shutil
33
from textwrap import dedent
44

5-
import pathlib
65
import pytest
76
import six
87
from django.conf import settings
98

109
from pytest_django_test.db_helpers import DB_NAME, TEST_DB_NAME
1110

11+
try:
12+
import pathlib
13+
except ImportError:
14+
import pathlib2 as pathlib
15+
1216
pytest_plugins = 'pytester'
1317

1418
REPOSITORY_ROOT = pathlib.Path(__file__).parent

0 commit comments

Comments
 (0)