99
1010os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "pylint_django.tests.settings" )
1111
12+ HERE = Path (__file__ ).parent
13+
1214try :
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"
2527except (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
5048class 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
0 commit comments