diff options
-rw-r--r-- | tests/functional/s/string/string_formatting_error.py | 20 | ||||
-rw-r--r-- | tests/functional/s/string/string_formatting_error.txt | 11 | ||||
-rw-r--r-- | tests/input/func_e13xx.py | 21 | ||||
-rw-r--r-- | tests/messages/func_e13xx.txt | 12 | ||||
-rw-r--r-- | tests/messages/func_e13xx_py30.txt | 11 |
5 files changed, 31 insertions, 44 deletions
diff --git a/tests/functional/s/string/string_formatting_error.py b/tests/functional/s/string/string_formatting_error.py new file mode 100644 index 000000000..97dfedc4a --- /dev/null +++ b/tests/functional/s/string/string_formatting_error.py @@ -0,0 +1,20 @@ +"""test string format error""" +# pylint: disable=print-statement,unsupported-binary-operation,line-too-long +from __future__ import print_function + +PARG_1 = PARG_2 = PARG_3 = 1 + + +def pprint(): + """Test string format""" + print("%s %s" % {'PARG_1': 1, 'PARG_2': 2}) # [too-few-format-args] + print("%s" % (PARG_1, PARG_2)) # [too-many-format-args] + print("%(PARG_1)d %d" % {'PARG_1': 1, 'PARG_2': 2}) # [mixed-format-string] + print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1}) # [missing-format-string-key] + print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1, 'PARG_2':2, 'PARG_3':3}) # [unused-format-string-key] + print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1, 2:3}) # [missing-format-string-key,bad-format-string-key] + print("%(PARG_1)d %(PARG_2)d" % (2, 3)) # [format-needs-mapping] + print("%(PARG_1)d %(PARG_2)d" % [2, 3]) # [format-needs-mapping] + print("%2z" % PARG_1) # [bad-format-character] + print("strange format %2" % PARG_2) # [truncated-format-string] + print("works in 3 %a" % 1) diff --git a/tests/functional/s/string/string_formatting_error.txt b/tests/functional/s/string/string_formatting_error.txt new file mode 100644 index 000000000..52b67f84f --- /dev/null +++ b/tests/functional/s/string/string_formatting_error.txt @@ -0,0 +1,11 @@ +too-few-format-args:10:10:pprint:Not enough arguments for format string +too-many-format-args:11:10:pprint:Too many arguments for format string +mixed-format-string:12:10:pprint:Mixing named and unnamed conversion specifiers in format string +missing-format-string-key:13:10:pprint:Missing key 'PARG_2' in format string dictionary +unused-format-string-key:14:10:pprint:Unused key 'PARG_3' in format string dictionary +bad-format-string-key:15:10:pprint:Format string dictionary key should be a string, not 2 +missing-format-string-key:15:10:pprint:Missing key 'PARG_2' in format string dictionary +format-needs-mapping:16:10:pprint:Expected mapping for format string, not Tuple +format-needs-mapping:17:10:pprint:Expected mapping for format string, not List +bad-format-character:18:10:pprint:Unsupported format character 'z' (0x7a) at index 2 +truncated-format-string:19:10:pprint:Format string ends in middle of conversion specifier diff --git a/tests/input/func_e13xx.py b/tests/input/func_e13xx.py deleted file mode 100644 index 227311cb6..000000000 --- a/tests/input/func_e13xx.py +++ /dev/null @@ -1,21 +0,0 @@ -"""test string format error -""" -# pylint: disable=print-statement,unsupported-binary-operation -from __future__ import print_function - -PARG_1 = PARG_2 = PARG_3 = 1 - -def pprint(): - """Test string format - """ - print("%s %s" % {'PARG_1': 1, 'PARG_2': 2}) # E1306 - print("%s" % (PARG_1, PARG_2)) # E1305 - print("%(PARG_1)d %d" % {'PARG_1': 1, 'PARG_2': 2}) # E1302 - print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1}) # E1304 - print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1, 'PARG_2':2, 'PARG_3':3}) #W1301 - print("%(PARG_1)d %(PARG_2)d" % {'PARG_1': 1, 2:3}) # W1300 E1304 - print("%(PARG_1)d %(PARG_2)d" % (2, 3)) # 1303 - print("%(PARG_1)d %(PARG_2)d" % [2, 3]) # 1303 - print("%2z" % PARG_1) - print("strange format %2" % PARG_2) - print("works in 3 %a" % 1) diff --git a/tests/messages/func_e13xx.txt b/tests/messages/func_e13xx.txt deleted file mode 100644 index 21b588f81..000000000 --- a/tests/messages/func_e13xx.txt +++ /dev/null @@ -1,12 +0,0 @@ -E: 11:pprint: Not enough arguments for format string -E: 12:pprint: Too many arguments for format string -E: 13:pprint: Mixing named and unnamed conversion specifiers in format string -E: 14:pprint: Missing key 'PARG_2' in format string dictionary -E: 16:pprint: Missing key 'PARG_2' in format string dictionary -E: 17:pprint: Expected mapping for format string, not Tuple -E: 18:pprint: Expected mapping for format string, not List -E: 19:pprint: Unsupported format character 'z' (0x7a) at index 2 -E: 20:pprint: Format string ends in middle of conversion specifier -E: 21:pprint: Unsupported format character 'a' (0x61) at index 12 -W: 15:pprint: Unused key 'PARG_3' in format string dictionary -W: 16:pprint: Format string dictionary key should be a string, not 2 diff --git a/tests/messages/func_e13xx_py30.txt b/tests/messages/func_e13xx_py30.txt deleted file mode 100644 index c7ffb64af..000000000 --- a/tests/messages/func_e13xx_py30.txt +++ /dev/null @@ -1,11 +0,0 @@ -E: 11:pprint: Not enough arguments for format string -E: 12:pprint: Too many arguments for format string -E: 13:pprint: Mixing named and unnamed conversion specifiers in format string -E: 14:pprint: Missing key 'PARG_2' in format string dictionary -E: 16:pprint: Missing key 'PARG_2' in format string dictionary -E: 17:pprint: Expected mapping for format string, not Tuple -E: 18:pprint: Expected mapping for format string, not List -E: 19:pprint: Unsupported format character 'z' (0x7a) at index 2 -E: 20:pprint: Format string ends in middle of conversion specifier -W: 15:pprint: Unused key 'PARG_3' in format string dictionary -W: 16:pprint: Format string dictionary key should be a string, not 2 |