diff options
| author | Ashley Whetter <ashley@awhetter.co.uk> | 2020-04-05 18:11:08 -0700 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2020-04-27 10:34:18 +0200 |
| commit | fb59ed86d5e463ebfdeb5d0af8539b7a8431aa15 (patch) | |
| tree | 460a7553ace1d0b8b6dde264cd97d6b4b0dd3d6f /tests/unittest_checker_logging.py | |
| parent | db0d55bcb19db4d8a9b7dd339d6ab554a4a1f017 (diff) | |
| download | pylint-git-fb59ed86d5e463ebfdeb5d0af8539b7a8431aa15.tar.gz | |
Brought back logging-fstring-interpolation
Diffstat (limited to 'tests/unittest_checker_logging.py')
| -rw-r--r-- | tests/unittest_checker_logging.py | 46 |
1 files changed, 5 insertions, 41 deletions
diff --git a/tests/unittest_checker_logging.py b/tests/unittest_checker_logging.py index 50ba2100f..a025fb6a2 100644 --- a/tests/unittest_checker_logging.py +++ b/tests/unittest_checker_logging.py @@ -30,7 +30,7 @@ class TestLoggingModuleDetection(CheckerTestCase): ) self.checker.visit_module(None) self.checker.visit_import(stmts[0]) - with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1])): + with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1], args=("lazy %",))): self.checker.visit_call(stmts[1]) def test_dont_crash_on_invalid_format_string(self): @@ -51,7 +51,7 @@ class TestLoggingModuleDetection(CheckerTestCase): ) self.checker.visit_module(None) self.checker.visit_import(stmts[0]) - with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1])): + with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1], args=("lazy %",))): self.checker.visit_call(stmts[1]) @set_config(logging_modules=["logging", "my.logging"]) @@ -64,7 +64,7 @@ class TestLoggingModuleDetection(CheckerTestCase): ) self.checker.visit_module(None) self.checker.visit_import(stmts[0]) - with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1])): + with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1], args=("lazy %",))): self.checker.visit_call(stmts[1]) def _assert_logging_format_no_messages(self, stmt): @@ -140,42 +140,6 @@ class TestLoggingModuleDetection(CheckerTestCase): @pytest.mark.skipif(sys.version_info < (3, 6), reason="F-string require >=3.6") @set_config(logging_format_style="new") def test_fstr_not_new_format_style_matching_arguments(self): - msg = "logging-format-interpolation" - args = ("{", "") + msg = "logging-fstring-interpolation" + args = ("lazy %",) self._assert_logging_format_message(msg, "(f'{named}')", args) - - @set_config(logging_format_style="fstr") - def test_modulo_not_fstr_format_style_matching_arguments(self): - msg = "logging-format-interpolation" - args = ("f-string", "") - with_too_many = False - self._assert_logging_format_message(msg, "('%s', 1)", args, with_too_many) - self._assert_logging_format_message( - msg, "('%(named)s', {'named': 1})", args, with_too_many - ) - self._assert_logging_format_message( - msg, "('%s %(named)s', 1, {'named': 1})", args, with_too_many - ) - - @set_config(logging_format_style="fstr") - def test_brace_not_fstr_format_style_matching_arguments(self): - msg = "logging-format-interpolation" - args = ("f-string", "") - with_too_many = False - self._assert_logging_format_message(msg, "('{}', 1)", args, with_too_many) - self._assert_logging_format_message(msg, "('{0}', 1)", args, with_too_many) - self._assert_logging_format_message( - msg, "('{named}', {'named': 1})", args, with_too_many - ) - self._assert_logging_format_message( - msg, "('{} {named}', 1, {'named': 1})", args, with_too_many - ) - self._assert_logging_format_message( - msg, "('{0} {named}', 1, {'named': 1})", args, with_too_many - ) - - @pytest.mark.skipif(sys.version_info < (3, 6), reason="F-string require >=3.6") - @set_config(logging_format_style="fstr") - def test_fstr_format_style_matching_arguments(self): - self._assert_logging_format_no_messages("(f'constant string')") - self._assert_logging_format_no_messages("(f'{named}')") |
