9
9
10
10
os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "pylint_django.tests.settings" )
11
11
12
+ HERE = Path (__file__ ).parent
13
+
12
14
try :
13
15
# pylint 2.5: test_functional has been moved to pylint.testutils
14
16
from pylint .testutils import FunctionalTestFile , LintModuleTest , lint_module_test
@@ -21,7 +23,7 @@ class test_dialect(csv.excel):
21
23
22
24
csv .register_dialect ("test" , test_dialect )
23
25
24
- lint_module_test .PYLINTRC = Path ( __file__ ). parent / "testing_pylintrc"
26
+ lint_module_test .PYLINTRC = HERE / "testing_pylintrc"
25
27
except (ImportError , AttributeError ):
26
28
# specify directly the directory containing test_functional.py
27
29
test_functional_dir = os .getenv ("PYLINT_TEST_FUNCTIONAL_DIR" , "" )
@@ -40,11 +42,7 @@ class test_dialect(csv.excel):
40
42
from test_functional import FunctionalTestFile , LintModuleTest
41
43
42
44
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" )]
48
46
49
47
50
48
class PylintDjangoLintModuleTest (LintModuleTest ):
@@ -75,13 +73,12 @@ def get_tests(input_dir="input", sort=False):
75
73
def _file_name (test ):
76
74
return test .base
77
75
78
- HERE = os .path .dirname (os .path .abspath (__file__ ))
79
- input_dir = os .path .join (HERE , input_dir )
76
+ input_dir = HERE / input_dir
80
77
81
78
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 ()) ))
85
82
86
83
# when testing the migrations plugin we need to sort by input file name
87
84
# because the plugin reports the errors in close() which appends them to the
0 commit comments