about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--tests/pylint/test_py2_compat.py25
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("""