summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tokenize.py
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2012-06-17 02:49:08 (GMT)
committerMeador Inge <meadori@gmail.com>2012-06-17 02:49:08 (GMT)
commit8d5c0b8c198374d0b88f30f04dd29d1f19c1c913 (patch)
tree82c76c228a2074c074e58249dc57b05f0d2776ef /Lib/test/test_tokenize.py
parent2d9db1dfceeb4e9b2c9572bd1abdbc3bc2b663e5 (diff)
downloadcpython-8d5c0b8c198374d0b88f30f04dd29d1f19c1c913.zip
cpython-8d5c0b8c198374d0b88f30f04dd29d1f19c1c913.tar.gz
cpython-8d5c0b8c198374d0b88f30f04dd29d1f19c1c913.tar.bz2
Issue #15054: Fix incorrect tokenization of 'b' string literals.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r--Lib/test/test_tokenize.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 915eda9..4c2e4e2 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -289,6 +289,82 @@ String literals
OP '+' (1, 29) (1, 30)
STRING 'R"ABC"' (1, 31) (1, 37)
+ >>> dump_tokens("u'abc' + U'abc'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING "u'abc'" (1, 0) (1, 6)
+ OP '+' (1, 7) (1, 8)
+ STRING "U'abc'" (1, 9) (1, 15)
+ >>> dump_tokens('u"abc" + U"abc"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING 'u"abc"' (1, 0) (1, 6)
+ OP '+' (1, 7) (1, 8)
+ STRING 'U"abc"' (1, 9) (1, 15)
+ >>> dump_tokens("ur'abc' + uR'abc' + Ur'abc' + UR'abc'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING "ur'abc'" (1, 0) (1, 7)
+ OP '+' (1, 8) (1, 9)
+ STRING "uR'abc'" (1, 10) (1, 17)
+ OP '+' (1, 18) (1, 19)
+ STRING "Ur'abc'" (1, 20) (1, 27)
+ OP '+' (1, 28) (1, 29)
+ STRING "UR'abc'" (1, 30) (1, 37)
+ >>> dump_tokens('ur"abc" + uR"abc" + Ur"abc" + UR"abc"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING 'ur"abc"' (1, 0) (1, 7)
+ OP '+' (1, 8) (1, 9)
+ STRING 'uR"abc"' (1, 10) (1, 17)
+ OP '+' (1, 18) (1, 19)
+ STRING 'Ur"abc"' (1, 20) (1, 27)
+ OP '+' (1, 28) (1, 29)
+ STRING 'UR"abc"' (1, 30) (1, 37)
+
+ >>> dump_tokens("b'abc' + B'abc'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING "b'abc'" (1, 0) (1, 6)
+ OP '+' (1, 7) (1, 8)
+ STRING "B'abc'" (1, 9) (1, 15)
+ >>> dump_tokens('b"abc" + B"abc"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING 'b"abc"' (1, 0) (1, 6)
+ OP '+' (1, 7) (1, 8)
+ STRING 'B"abc"' (1, 9) (1, 15)
+ >>> dump_tokens("br'abc' + bR'abc' + Br'abc' + BR'abc'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING "br'abc'" (1, 0) (1, 7)
+ OP '+' (1, 8) (1, 9)
+ STRING "bR'abc'" (1, 10) (1, 17)
+ OP '+' (1, 18) (1, 19)
+ STRING "Br'abc'" (1, 20) (1, 27)
+ OP '+' (1, 28) (1, 29)
+ STRING "BR'abc'" (1, 30) (1, 37)
+ >>> dump_tokens('br"abc" + bR"abc" + Br"abc" + BR"abc"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING 'br"abc"' (1, 0) (1, 7)
+ OP '+' (1, 8) (1, 9)
+ STRING 'bR"abc"' (1, 10) (1, 17)
+ OP '+' (1, 18) (1, 19)
+ STRING 'Br"abc"' (1, 20) (1, 27)
+ OP '+' (1, 28) (1, 29)
+ STRING 'BR"abc"' (1, 30) (1, 37)
+ >>> dump_tokens("rb'abc' + rB'abc' + Rb'abc' + RB'abc'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING "rb'abc'" (1, 0) (1, 7)
+ OP '+' (1, 8) (1, 9)
+ STRING "rB'abc'" (1, 10) (1, 17)
+ OP '+' (1, 18) (1, 19)
+ STRING "Rb'abc'" (1, 20) (1, 27)
+ OP '+' (1, 28) (1, 29)
+ STRING "RB'abc'" (1, 30) (1, 37)
+ >>> dump_tokens('rb"abc" + rB"abc" + Rb"abc" + RB"abc"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ STRING 'rb"abc"' (1, 0) (1, 7)
+ OP '+' (1, 8) (1, 9)
+ STRING 'rB"abc"' (1, 10) (1, 17)
+ OP '+' (1, 18) (1, 19)
+ STRING 'Rb"abc"' (1, 20) (1, 27)
+ OP '+' (1, 28) (1, 29)
+ STRING 'RB"abc"' (1, 30) (1, 37)
+
Operators
>>> dump_tokens("def d22(a, b, c=2, d=2, *k): pass")