Skip to content

Commit

Permalink
Use pathlib2 (#636)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adamchainz authored and blueyed committed Aug 20, 2018
1 parent 5619f16 commit 43ff7bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pytest_django/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import sys
import types

import pathlib
import pytest

from .django_compat import is_django_unittest # noqa
Expand All @@ -38,6 +37,11 @@

from .lazy_django import django_settings_is_configured, skip_if_no_django

try:
import pathlib
except ImportError:
import pathlib2 as pathlib


SETTINGS_MODULE_ENV = 'DJANGO_SETTINGS_MODULE'
CONFIGURATION_ENV = 'DJANGO_CONFIGURATION'
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def read(fname):
setup_requires=['setuptools_scm>=1.11.1'],
install_requires=[
'pytest>=3.6',
'pathlib;python_version<"3.4"',
'pathlib2;python_version<"3.4"',
],
extras_require={
'docs': [
Expand Down
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
import shutil
from textwrap import dedent

import pathlib
import pytest
import six
from django.conf import settings

from pytest_django_test.db_helpers import DB_NAME, TEST_DB_NAME

try:
import pathlib
except ImportError:
import pathlib2 as pathlib

pytest_plugins = 'pytester'

REPOSITORY_ROOT = pathlib.Path(__file__).parent
Expand Down

0 comments on commit 43ff7bb

Please sign in to comment.