summaryrefslogtreecommitdiff
path: root/pylint/test/unittest_checker_logging.py
diff options
context:
space:
mode:
authorAlan Chan <achan961117@gmail.com>2018-10-04 15:28:36 +0800
committerClaudiu Popa <pcmanticore@gmail.com>2018-10-04 09:28:36 +0200
commit0dd573faae1ad339c07f789270002f8faf2a3691 (patch)
tree5b139a624a01a1e86a2cbe0eb920d80ca167bc41 /pylint/test/unittest_checker_logging.py
parent540e26db2e05c4f4f555db54d4c046ceff0e7763 (diff)
downloadpylint-git-0dd573faae1ad339c07f789270002f8faf2a3691.tar.gz
New option: logging-format-style for logging checker (#2521)
logging-format-style accepts one of '%' or '{', (defaults to '%'). When '{' is selected, logging checker assumes str.format() style format strings for calls to the logging. pylint was unable to count the required number of args for the format string when the format string was using the `{` format. The new feature indirectly fixes that by allowing the proper interpretation of that format string.
Diffstat (limited to 'pylint/test/unittest_checker_logging.py')
-rw-r--r--pylint/test/unittest_checker_logging.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pylint/test/unittest_checker_logging.py b/pylint/test/unittest_checker_logging.py
index ef2b40b0f..62891af0b 100644
--- a/pylint/test/unittest_checker_logging.py
+++ b/pylint/test/unittest_checker_logging.py
@@ -62,3 +62,16 @@ class TestLoggingModuleDetection(CheckerTestCase):
self.checker.visit_import(stmts[0])
with self.assertAddsMessages(Message("logging-not-lazy", node=stmts[1])):
self.checker.visit_call(stmts[1])
+
+ @set_config(logging_format_style="{")
+ def test_brace_format_style(self):
+ stmts = astroid.extract_node(
+ """
+ import logging #@
+ logging.error('{}', 1) #@
+ """
+ )
+ self.checker.visit_module(None)
+ self.checker.visit_import(stmts[0])
+ with self.assertNoMessages():
+ self.checker.visit_call(stmts[1])