summaryrefslogtreecommitdiff
path: root/tests/functional/l/logging_format_interpolation.py
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2019-07-21 10:56:00 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-09-10 11:20:16 +0200
commit997d9d1ec72fce84903da4784ac56fbe30e6da1e (patch)
tree9a0ddd3ba0975e045e408d9793cce096ecaeaa75 /tests/functional/l/logging_format_interpolation.py
parent676ec55ff9d8f10e52b740a57e4e62a3255d6709 (diff)
downloadpylint-git-997d9d1ec72fce84903da4784ac56fbe30e6da1e.tar.gz
[functional tests] Rename example_functional_tests.py => e/example_functional_tests.py
Permit to navigate in the functional tests easier.
Diffstat (limited to 'tests/functional/l/logging_format_interpolation.py')
-rw-r--r--tests/functional/l/logging_format_interpolation.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/functional/l/logging_format_interpolation.py b/tests/functional/l/logging_format_interpolation.py
new file mode 100644
index 000000000..5f61d6baf
--- /dev/null
+++ b/tests/functional/l/logging_format_interpolation.py
@@ -0,0 +1,39 @@
+# pylint: disable=E1101, no-absolute-import, import-error,line-too-long, missing-docstring,wrong-import-order,wrong-import-position
+# pylint: disable=invalid-name
+try:
+ import __builtin__ as builtins
+except ImportError:
+ import builtins
+
+# Muck up the names in an effort to confuse...
+import logging as renamed_logging
+import os as logging
+from uninferable import UNINFERABLE
+
+FORMAT_STR = '{0}, {1}'
+
+# Statements that should be flagged:
+renamed_logging.debug('{0}, {1}'.format(4, 5)) # [logging-format-interpolation]
+renamed_logging.log(renamed_logging.DEBUG, 'msg: {}'.format('Run!')) # [logging-format-interpolation]
+renamed_logging.debug(FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
+renamed_logging.log(renamed_logging.DEBUG, FORMAT_STR.format(4, 5)) # [logging-format-interpolation]
+renamed_logging.info("Read {l} rows".format(l=123456789)) # [logging-format-interpolation]
+
+# Statements that should not be flagged:
+renamed_logging.debug(format(66, 'x'))
+renamed_logging.debug(builtins.format(66, 'x'))
+renamed_logging.log(renamed_logging.DEBUG, 'msg: Run!'.upper())
+logging.debug('{0}, {1}'.format(4, 5))
+logging.log(logging.DEBUG, 'msg: {}'.format('Run!'))
+renamed_logging.info("Read {l:,d} rows".format(l=123456789))
+renamed_logging.info(UNINFERABLE.format(l=123456789))
+
+
+class Logger(renamed_logging.Logger):
+ pass
+
+custom_logger = Logger('three')
+
+# Currently disabled until we get this in https://github.com/PyCQA/astroid/pull/637
+# custom_logger.info('testing {0}'.format('info'))
+# custom_logger.info('testing %s' % 'info')