From cd50f416aeb1f8b66f152bdbf941b7a149a5939c Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 9 Mar 2021 20:37:14 +0100 Subject: Migrate func_e12xx.py to new functional tests --- tests/functional/s/string/string_log_formatting.py | 28 ++++++++++++++++++++++ .../functional/s/string/string_log_formatting.txt | 6 +++++ tests/input/func_e12xx.py | 28 ---------------------- tests/messages/func_e12xx.txt | 6 ----- tests/test_func.py | 2 +- 5 files changed, 35 insertions(+), 35 deletions(-) create mode 100644 tests/functional/s/string/string_log_formatting.py create mode 100644 tests/functional/s/string/string_log_formatting.txt delete mode 100644 tests/input/func_e12xx.py delete mode 100644 tests/messages/func_e12xx.txt diff --git a/tests/functional/s/string/string_log_formatting.py b/tests/functional/s/string/string_log_formatting.py new file mode 100644 index 000000000..0aca73dbc --- /dev/null +++ b/tests/functional/s/string/string_log_formatting.py @@ -0,0 +1,28 @@ +# pylint: disable=E1101, no-absolute-import +"""Test checking of log format strings +""" + +import logging + +__revision__ = '' + + +def pprint(): + """Test string format in logging statements. + """ + # These should all emit lint errors: + logging.info(0, '') # [logging-too-many-args] + logging.info('', '') # [logging-too-many-args] + logging.info('%s%', '') # [logging-format-truncated] + logging.info('%s%s', '') # [logging-too-few-args] + logging.info('%s%y', '', '') # [logging-unsupported-format] + logging.info('%s%s', '', '', '') # [logging-too-many-args] + + # These should be okay: + logging.info(1) + logging.info(True) + logging.info('') + logging.info('%s%') + logging.info('%s', '') + logging.info('%s%%', '') + logging.info('%s%s', '', '') diff --git a/tests/functional/s/string/string_log_formatting.txt b/tests/functional/s/string/string_log_formatting.txt new file mode 100644 index 000000000..aec9c26d5 --- /dev/null +++ b/tests/functional/s/string/string_log_formatting.txt @@ -0,0 +1,6 @@ +logging-too-many-args:14:4:pprint:Too many arguments for logging format string +logging-too-many-args:15:4:pprint:Too many arguments for logging format string +logging-format-truncated:16:4:pprint:Logging format string ends in middle of conversion specifier +logging-too-few-args:17:4:pprint:Not enough arguments for logging format string +logging-unsupported-format:18:4:pprint:Unsupported logging format character 'y' (0x79) at index 3 +logging-too-many-args:19:4:pprint:Too many arguments for logging format string diff --git a/tests/input/func_e12xx.py b/tests/input/func_e12xx.py deleted file mode 100644 index 74984d998..000000000 --- a/tests/input/func_e12xx.py +++ /dev/null @@ -1,28 +0,0 @@ -# pylint: disable=E1101, no-absolute-import -"""Test checking of log format strings -""" - -import logging - -__revision__ = '' - - -def pprint(): - """Test string format in logging statements. - """ - # These should all emit lint errors: - logging.info(0, '') # 1205 - logging.info('', '') # 1205 - logging.info('%s%', '') # 1201 - logging.info('%s%s', '') # 1206 - logging.info('%s%y', '', '') # 1200 - logging.info('%s%s', '', '', '') # 1205 - - # These should be okay: - logging.info(1) - logging.info(True) - logging.info('') - logging.info('%s%') - logging.info('%s', '') - logging.info('%s%%', '') - logging.info('%s%s', '', '') diff --git a/tests/messages/func_e12xx.txt b/tests/messages/func_e12xx.txt deleted file mode 100644 index 92640d256..000000000 --- a/tests/messages/func_e12xx.txt +++ /dev/null @@ -1,6 +0,0 @@ -E: 14:pprint: Too many arguments for logging format string -E: 15:pprint: Too many arguments for logging format string -E: 16:pprint: Logging format string ends in middle of conversion specifier -E: 17:pprint: Not enough arguments for logging format string -E: 18:pprint: Unsupported logging format character 'y' (0x79) at index 3 -E: 19:pprint: Too many arguments for logging format string diff --git a/tests/test_func.py b/tests/test_func.py index 170055918..f96e53c28 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -120,7 +120,7 @@ def gen_tests(filter_rgx): tests.append((module_file, messages_file, dependencies)) if UPDATE_FILE.exists(): return tests - assert len(tests) < 28, "Please do not add new test cases here." + assert len(tests) < 19, "Please do not add new test cases here." return tests -- cgit v1.2.1