Skip to content

Commit 0b08f88

Browse files
committed
Fixing up finding of test files and setting search path for modules
1 parent 7d74a88 commit 0b08f88

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

pylint_django/tests/test_func.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pylint_django.tests.settings")
1111

12+
HERE = Path(__file__).parent
13+
1214
try:
1315
# pylint 2.5: test_functional has been moved to pylint.testutils
1416
from pylint.testutils import FunctionalTestFile, LintModuleTest, lint_module_test
@@ -21,7 +23,7 @@ class test_dialect(csv.excel):
2123

2224
csv.register_dialect("test", test_dialect)
2325

24-
lint_module_test.PYLINTRC = Path(__file__).parent / "testing_pylintrc"
26+
lint_module_test.PYLINTRC = HERE / "testing_pylintrc"
2527
except (ImportError, AttributeError):
2628
# specify directly the directory containing test_functional.py
2729
test_functional_dir = os.getenv("PYLINT_TEST_FUNCTIONAL_DIR", "")
@@ -40,11 +42,7 @@ class test_dialect(csv.excel):
4042
from test_functional import FunctionalTestFile, LintModuleTest
4143

4244

43-
# alter sys.path again because the tests now live as a subdirectory
44-
# of pylint_django
45-
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
46-
# so we can find migrations
47-
sys.path.append(os.path.join(os.path.dirname(__file__), "input"))
45+
sys.path += [str(p.absolute()) for p in (HERE, HERE / "../../", HERE / "input")]
4846

4947

5048
class PylintDjangoLintModuleTest(LintModuleTest):
@@ -75,13 +73,12 @@ def get_tests(input_dir="input", sort=False):
7573
def _file_name(test):
7674
return test.base
7775

78-
HERE = os.path.dirname(os.path.abspath(__file__))
79-
input_dir = os.path.join(HERE, input_dir)
76+
input_dir = HERE / input_dir
8077

8178
suite = []
82-
for fname in os.listdir(input_dir):
83-
if fname != "__init__.py" and fname.endswith(".py"):
84-
suite.append(FunctionalTestFile(input_dir, fname))
79+
for fname in input_dir.iterdir():
80+
if fname.name != "__init__.py" and fname.name.endswith(".py"):
81+
suite.append(FunctionalTestFile(str(input_dir.absolute()), str(fname.absolute())))
8582

8683
# when testing the migrations plugin we need to sort by input file name
8784
# because the plugin reports the errors in close() which appends them to the

setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,15 @@
2323
],
2424
extras_require={
2525
"with_django": ["Django"],
26-
"for_tests": ["django_tables2", "factory-boy", "coverage", "pytest", "wheel", "django-tastypie"],
26+
"for_tests": [
27+
"django_tables2",
28+
"factory-boy",
29+
"coverage",
30+
"pytest",
31+
"wheel",
32+
"django-tastypie",
33+
"pylint>=2.13",
34+
],
2735
},
2836
license="GPLv2",
2937
classifiers=[

0 commit comments

Comments
 (0)