|
6 | 6 | """
|
7 | 7 |
|
8 | 8 | import sys
|
9 |
| -import platform |
10 | 9 | import os
|
11 | 10 | from os.path import abspath, dirname, join
|
12 | 11 | import unittest
|
13 | 12 |
|
| 13 | +import astroid |
14 | 14 | from pylint.testutils import TestReporter
|
15 |
| -from pylint.lint import PyLinter |
16 | 15 | from pylint import checkers
|
17 | 16 | from pylint import epylint
|
| 17 | +from pylint import lint |
18 | 18 |
|
19 | 19 | test_reporter = TestReporter()
|
20 |
| -linter = PyLinter() |
| 20 | +linter = lint.PyLinter() |
21 | 21 | linter.set_reporter(test_reporter)
|
22 | 22 | linter.disable('I')
|
23 | 23 | linter.config.persistent = 0
|
@@ -61,24 +61,6 @@ def test_check_package___init__(self):
|
61 | 61 | sys.path.pop(0)
|
62 | 62 | os.chdir(cwd)
|
63 | 63 |
|
64 |
| - def test_numarray_inference(self): |
65 |
| - try: |
66 |
| - from numarray import random_array |
67 |
| - except ImportError: |
68 |
| - self.skipTest('test skipped: numarray.random_array is not available') |
69 |
| - linter.check(join(REGR_DATA, 'numarray_inf.py')) |
70 |
| - got = linter.reporter.finalize().strip() |
71 |
| - self.assertEqual(got, "E: 5: Instance of 'int' has no 'astype' member (but some types could not be inferred)") |
72 |
| - |
73 |
| - def test_numarray_import(self): |
74 |
| - try: |
75 |
| - import numarray |
76 |
| - except ImportError: |
77 |
| - self.skipTest('test skipped: numarray is not available') |
78 |
| - linter.check(join(REGR_DATA, 'numarray_import.py')) |
79 |
| - got = linter.reporter.finalize().strip() |
80 |
| - self.assertEqual(got, '') |
81 |
| - |
82 | 64 | def test_class__doc__usage(self):
|
83 | 65 | linter.check(join(REGR_DATA, 'classdoc_usage.py'))
|
84 | 66 | got = linter.reporter.finalize().strip()
|
@@ -138,6 +120,20 @@ def test_epylint_does_not_block_on_huge_files(self):
|
138 | 120 | output = out.read(10)
|
139 | 121 | self.assertIsInstance(output, str)
|
140 | 122 |
|
| 123 | + def test_pylint_config_attr(self): |
| 124 | + mod = astroid.MANAGER.ast_from_module_name('pylint.lint') |
| 125 | + pylinter = mod['PyLinter'] |
| 126 | + expect = ['OptionsManagerMixIn', 'object', 'MessagesHandlerMixIn', |
| 127 | + 'ReportsHandlerMixIn', 'BaseTokenChecker', 'BaseChecker', |
| 128 | + 'OptionsProviderMixIn'] |
| 129 | + self.assertListEqual([c.name for c in pylinter.ancestors()], |
| 130 | + expect) |
| 131 | + self.assertTrue(list(astroid.Instance(pylinter).getattr('config'))) |
| 132 | + inferred = list(astroid.Instance(pylinter).igetattr('config')) |
| 133 | + self.assertEqual(len(inferred), 1) |
| 134 | + self.assertEqual(inferred[0].root().name, 'optparse') |
| 135 | + self.assertEqual(inferred[0].name, 'Values') |
| 136 | + |
141 | 137 |
|
142 | 138 | if __name__ == '__main__':
|
143 | 139 | unittest.main()
|
0 commit comments