summaryrefslogtreecommitdiff
path: root/pylint/test/test_regr.py
diff options
context:
space:
mode:
Diffstat (limited to 'pylint/test/test_regr.py')
-rw-r--r--pylint/test/test_regr.py87
1 files changed, 49 insertions, 38 deletions
diff --git a/pylint/test/test_regr.py b/pylint/test/test_regr.py
index c96cca0e4..c3e026015 100644
--- a/pylint/test/test_regr.py
+++ b/pylint/test/test_regr.py
@@ -25,7 +25,7 @@ import pylint.testutils as testutils
from pylint import epylint
-REGR_DATA = join(dirname(abspath(__file__)), 'regrtest_data')
+REGR_DATA = join(dirname(abspath(__file__)), "regrtest_data")
sys.path.insert(1, REGR_DATA)
try:
@@ -41,7 +41,7 @@ def reporter(reporter):
@pytest.fixture(scope="module")
def disable(disable):
- return ['I']
+ return ["I"]
@pytest.fixture
@@ -57,36 +57,41 @@ def Equals(expected):
return lambda got: got == expected
-@pytest.mark.parametrize("file_name, check", [
- ("package.__init__", Equals("")),
- ("precedence_test", Equals("")),
- ("import_package_subpackage_module", Equals("")),
- ("pylint.checkers.__init__", lambda x: '__path__' not in x),
- (join(REGR_DATA, "classdoc_usage.py"), Equals("")),
- (join(REGR_DATA, "module_global.py"), Equals("")),
- (join(REGR_DATA, "decimal_inference.py"), Equals("")),
- (join(REGR_DATA, 'absimp', 'string.py'), Equals("")),
- (join(REGR_DATA, 'bad_package'),
- lambda x: "Unused import missing" in x),
-
-])
+@pytest.mark.parametrize(
+ "file_name, check",
+ [
+ ("package.__init__", Equals("")),
+ ("precedence_test", Equals("")),
+ ("import_package_subpackage_module", Equals("")),
+ ("pylint.checkers.__init__", lambda x: "__path__" not in x),
+ (join(REGR_DATA, "classdoc_usage.py"), Equals("")),
+ (join(REGR_DATA, "module_global.py"), Equals("")),
+ (join(REGR_DATA, "decimal_inference.py"), Equals("")),
+ (join(REGR_DATA, "absimp", "string.py"), Equals("")),
+ (join(REGR_DATA, "bad_package"), lambda x: "Unused import missing" in x),
+ ],
+)
def test_package(finalize_linter, file_name, check):
finalize_linter.check(file_name)
got = finalize_linter.reporter.finalize().strip()
assert check(got)
-@pytest.mark.parametrize("file_name", [
- join(REGR_DATA, 'import_assign.py'),
- join(REGR_DATA, 'special_attr_scope_lookup_crash.py'),
- join(REGR_DATA, 'try_finally_disable_msg_crash'),
-])
+@pytest.mark.parametrize(
+ "file_name",
+ [
+ join(REGR_DATA, "import_assign.py"),
+ join(REGR_DATA, "special_attr_scope_lookup_crash.py"),
+ join(REGR_DATA, "try_finally_disable_msg_crash"),
+ ],
+)
def test_crash(finalize_linter, file_name):
finalize_linter.check(file_name)
-@pytest.mark.parametrize("fname", [x for x in os.listdir(REGR_DATA)
- if x.endswith('_crash.py')])
+@pytest.mark.parametrize(
+ "fname", [x for x in os.listdir(REGR_DATA) if x.endswith("_crash.py")]
+)
def test_descriptor_crash(fname, finalize_linter):
finalize_linter.check(join(REGR_DATA, fname))
finalize_linter.reporter.finalize().strip()
@@ -95,7 +100,7 @@ def test_descriptor_crash(fname, finalize_linter):
@pytest.fixture
def modify_path():
cwd = os.getcwd()
- sys.path.insert(0, '')
+ sys.path.insert(0, "")
yield
sys.path.pop(0)
os.chdir(cwd)
@@ -103,26 +108,32 @@ def modify_path():
@pytest.mark.usefixtures("modify_path")
def test_check_package___init__(finalize_linter):
- filename = 'package.__init__'
+ filename = "package.__init__"
finalize_linter.check(filename)
- checked = list(finalize_linter.stats['by_module'].keys())
+ checked = list(finalize_linter.stats["by_module"].keys())
assert checked == [filename]
- os.chdir(join(REGR_DATA, 'package'))
- finalize_linter.check('__init__')
- checked = list(finalize_linter.stats['by_module'].keys())
- assert checked == ['__init__']
+ os.chdir(join(REGR_DATA, "package"))
+ finalize_linter.check("__init__")
+ checked = list(finalize_linter.stats["by_module"].keys())
+ assert checked == ["__init__"]
def test_pylint_config_attr():
- mod = astroid.MANAGER.ast_from_module_name('pylint.lint')
- pylinter = mod['PyLinter']
- expect = ['OptionsManagerMixIn', 'object', 'MessagesHandlerMixIn',
- 'ReportsHandlerMixIn', 'BaseTokenChecker', 'BaseChecker',
- 'OptionsProviderMixIn']
+ mod = astroid.MANAGER.ast_from_module_name("pylint.lint")
+ pylinter = mod["PyLinter"]
+ expect = [
+ "OptionsManagerMixIn",
+ "object",
+ "MessagesHandlerMixIn",
+ "ReportsHandlerMixIn",
+ "BaseTokenChecker",
+ "BaseChecker",
+ "OptionsProviderMixIn",
+ ]
assert [c.name for c in pylinter.ancestors()] == expect
- assert list(astroid.Instance(pylinter).getattr('config'))
- inferred = list(astroid.Instance(pylinter).igetattr('config'))
+ assert list(astroid.Instance(pylinter).getattr("config"))
+ inferred = list(astroid.Instance(pylinter).igetattr("config"))
assert len(inferred) == 1
- assert inferred[0].root().name == 'optparse'
- assert inferred[0].name == 'Values'
+ assert inferred[0].root().name == "optparse"
+ assert inferred[0].name == "Values"