diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2024-02-19 14:54:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 14:54:10 (GMT) |
commit | ecf16ee50e42f979624e55fa343a8522942db2e7 (patch) | |
tree | 2946c2a59037f094c7677e4dbe4d49209869002c /Lib/test/test_tokenize.py | |
parent | d504968983c5cd5ddbdf73ccd3693ffb89e7952f (diff) | |
download | cpython-ecf16ee50e42f979624e55fa343a8522942db2e7.zip cpython-ecf16ee50e42f979624e55fa343a8522942db2e7.tar.gz cpython-ecf16ee50e42f979624e55fa343a8522942db2e7.tar.bz2 |
gh-115154: Fix untokenize handling of unicode named literals (#115171)
Diffstat (limited to 'Lib/test/test_tokenize.py')
-rw-r--r-- | Lib/test/test_tokenize.py | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py index 21e8637..4428e8c 100644 --- a/Lib/test/test_tokenize.py +++ b/Lib/test/test_tokenize.py @@ -1877,6 +1877,43 @@ class TestRoundtrip(TestCase): " print('Can not import' # comment2\n)" "else: print('Loaded')\n") + self.check_roundtrip("f'\\N{EXCLAMATION MARK}'") + self.check_roundtrip(r"f'\\N{SNAKE}'") + self.check_roundtrip(r"f'\\N{{SNAKE}}'") + self.check_roundtrip(r"f'\N{SNAKE}'") + self.check_roundtrip(r"f'\\\N{SNAKE}'") + self.check_roundtrip(r"f'\\\\\N{SNAKE}'") + self.check_roundtrip(r"f'\\\\\\\N{SNAKE}'") + + self.check_roundtrip(r"f'\\N{1}'") + self.check_roundtrip(r"f'\\\\N{2}'") + self.check_roundtrip(r"f'\\\\\\N{3}'") + self.check_roundtrip(r"f'\\\\\\\\N{4}'") + + self.check_roundtrip(r"f'\\N{{'") + self.check_roundtrip(r"f'\\\\N{{'") + self.check_roundtrip(r"f'\\\\\\N{{'") + self.check_roundtrip(r"f'\\\\\\\\N{{'") + cases = [ + """ +if 1: + "foo" +"bar" +""", + """ +if 1: + ("foo" + "bar") +""", + """ +if 1: + "foo" + "bar" +""" ] + for case in cases: + self.check_roundtrip(case) + + def test_continuation(self): # Balancing continuation self.check_roundtrip("a = (3,4, \n" @@ -1911,9 +1948,6 @@ class TestRoundtrip(TestCase): tempdir = os.path.dirname(__file__) or os.curdir testfiles = glob.glob(os.path.join(glob.escape(tempdir), "test*.py")) - # TODO: Remove this once we can untokenize PEP 701 syntax - testfiles.remove(os.path.join(tempdir, "test_fstring.py")) - if not support.is_resource_enabled("cpu"): testfiles = random.sample(testfiles, 10) |