Skip to content

Commit fc0ed97

Browse files
committed
Import test from astroid and remove old regression tests for libraries we do not have installed (they were pretty much useless)
1 parent 16fc64e commit fc0ed97

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

pylint/test/test_regr.py

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66
"""
77

88
import sys
9-
import platform
109
import os
1110
from os.path import abspath, dirname, join
1211
import unittest
1312

13+
import astroid
1414
from pylint.testutils import TestReporter
15-
from pylint.lint import PyLinter
1615
from pylint import checkers
1716
from pylint import epylint
17+
from pylint import lint
1818

1919
test_reporter = TestReporter()
20-
linter = PyLinter()
20+
linter = lint.PyLinter()
2121
linter.set_reporter(test_reporter)
2222
linter.disable('I')
2323
linter.config.persistent = 0
@@ -61,24 +61,6 @@ def test_check_package___init__(self):
6161
sys.path.pop(0)
6262
os.chdir(cwd)
6363

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-
8264
def test_class__doc__usage(self):
8365
linter.check(join(REGR_DATA, 'classdoc_usage.py'))
8466
got = linter.reporter.finalize().strip()
@@ -138,6 +120,20 @@ def test_epylint_does_not_block_on_huge_files(self):
138120
output = out.read(10)
139121
self.assertIsInstance(output, str)
140122

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+
141137

142138
if __name__ == '__main__':
143139
unittest.main()

0 commit comments

Comments
 (0)