|
5 | 5 |
|
6 | 6 | import pylint |
7 | 7 |
|
8 | | -if pylint.__version__ >= '2.4': |
9 | | - # after version 2.4 pylint stopped shipping the test directory |
10 | | - # as part of the package so we check it out locally for testing |
11 | | - sys.path.append(os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests')) |
12 | | -else: |
13 | | - # because there's no __init__ file in pylint/test/ |
14 | | - sys.path.append(os.path.join(os.path.dirname(pylint.__file__), 'test')) |
15 | 8 |
|
16 | | -import test_functional # noqa: E402 |
| 9 | +try: |
| 10 | + # pylint 2.5: test_functional has been moved to pylint.testutils |
| 11 | + from pylint.testutils import FunctionalTestFile, LintModuleTest |
| 12 | +except (ImportError, AttributeError): |
| 13 | + # specify directly the directory containing test_functional.py |
| 14 | + test_functional_dir = os.getenv('PYLINT_TEST_FUNCTIONAL_DIR', '') |
| 15 | + |
| 16 | + # otherwise look for in in ~/pylint/tests - pylint 2.4 |
| 17 | + # this is the pylint git checkout dir, not the pylint module dir |
| 18 | + if not os.path.isdir(test_functional_dir): |
| 19 | + test_functional_dir = os.path.join(os.getenv('HOME', '/home/travis'), 'pylint', 'tests') |
| 20 | + |
| 21 | + # or site-packages/pylint/test/ - pylint before 2.4 |
| 22 | + if not os.path.isdir(test_functional_dir): |
| 23 | + test_functional_dir = os.path.join(os.path.dirname(pylint.__file__), 'test') |
| 24 | + |
| 25 | + sys.path.append(test_functional_dir) |
| 26 | + |
| 27 | + from test_functional import FunctionalTestFile, LintModuleTest |
| 28 | + |
17 | 29 |
|
18 | 30 | # alter sys.path again because the tests now live as a subdirectory |
19 | 31 | # of pylint_django |
|
22 | 34 | sys.path.append(os.path.join(os.path.dirname(__file__), 'input')) |
23 | 35 |
|
24 | 36 |
|
25 | | -class PylintDjangoLintModuleTest(test_functional.LintModuleTest): |
| 37 | +class PylintDjangoLintModuleTest(LintModuleTest): |
26 | 38 | """ |
27 | 39 | Only used so that we can load this plugin into the linter! |
28 | 40 | """ |
@@ -53,7 +65,7 @@ def _file_name(test): |
53 | 65 | suite = [] |
54 | 66 | for fname in os.listdir(input_dir): |
55 | 67 | if fname != '__init__.py' and fname.endswith('.py'): |
56 | | - suite.append(test_functional.FunctionalTestFile(input_dir, fname)) |
| 68 | + suite.append(FunctionalTestFile(input_dir, fname)) |
57 | 69 |
|
58 | 70 | # when testing the db_performance plugin we need to sort by input file name |
59 | 71 | # because the plugin reports the errors in close() which appends them to the |
|
0 commit comments