diff options
author | toonn <toonn@toonn.io> | 2022-02-05 19:31:22 +0100 |
---|---|---|
committer | toonn <toonn@toonn.io> | 2022-02-05 19:31:22 +0100 |
commit | 7a5f820e760c7ce2f93e2a5f0e91677b46252ea9 (patch) | |
tree | 6f4130ac9594adda5d6a1dd3fb97e87dc7fcc3ac /tests/pylint/test_py2_compat.py | |
parent | fcd0d50f8b952cc70f65639742cee5e194d84401 (diff) | |
parent | e3c90e2f758ebd94de8cd228d27ef5e1e4cda817 (diff) | |
download | ranger-7a5f820e760c7ce2f93e2a5f0e91677b46252ea9.tar.gz |
Merge branch 'pylint'
Diffstat (limited to 'tests/pylint/test_py2_compat.py')
-rw-r--r-- | tests/pylint/test_py2_compat.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/pylint/test_py2_compat.py b/tests/pylint/test_py2_compat.py index 2eb51599..33fc5681 100644 --- a/tests/pylint/test_py2_compat.py +++ b/tests/pylint/test_py2_compat.py @@ -4,6 +4,7 @@ import py2_compat import astroid import pylint.testutils +from pylint.interfaces import HIGH from sys import version_info PY2 = version_info[0] < 3 @@ -25,6 +26,7 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): pylint.testutils.MessageTest( msg_id='old-style-class', node=oldstyle_class, + confidence=HIGH, ), ): self.checker.visit_classdef(oldstyle_class) @@ -56,6 +58,7 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): pylint.testutils.MessageTest( msg_id='print-without-import', node=print_function_call, + confidence=HIGH, ), ): self.checker.visit_call(print_function_call) @@ -95,6 +98,7 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): pylint.testutils.MessageTest( msg_id='print-without-import', node=early_print_function_call, + confidence=HIGH, ), ): self.checker.visit_call(early_print_function_call) @@ -111,6 +115,7 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): pylint.testutils.MessageTest( msg_id='implicit-format-spec', node=implicit_format_spec, + confidence=HIGH, ), ): self.checker.visit_call(implicit_format_spec) @@ -134,6 +139,7 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): pylint.testutils.MessageTest( msg_id='with-popen23', node=with_Popen, + confidence=HIGH, ), ): self.checker.visit_with(with_subprocess_Popen) @@ -141,6 +147,25 @@ class TestPy2CompatibilityChecker(pylint.testutils.CheckerTestCase): with self.assertNoMessages(): self.checker.visit_with(with_Popen23) + def test_use_format(self): + old_format, new_format, f_string = astroid.extract_node(""" + "2 + 2 is %s" % (2+2) #@ + "2 + 2 is {0}".format(2+2) #@ + f"2 + 2 is {2+2}" #@ + """) + + with self.assertAddsMessages( + pylint.testutils.MessageTest( + msg_id='use-format-method', + node=f_string, + confidence=HIGH, + ), + ): + self.checker.visit_joinedstr(f_string) + with self.assertNoMessages(): + self.checker.visit_joinedstr(old_format) + self.checker.visit_joinedstr(new_format) + # # These checks still exist as old-division and no-absolute-import # def test_division_without_import(self): # division = astroid.extract_node(""" |