Skip to content

Commit

Permalink
Merge pull request #46 from mgmacias95/fstring-grammar-rebased-after-…
Browse files Browse the repository at this point in the history
…sprint

test: Fix fstring related tests in test_tokenize.py
  • Loading branch information
pablogsal authored Mar 24, 2023
2 parents b41a3b8 + 3c2aea4 commit 081f5a2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Lib/test/test_tokenize.py
Original file line number Diff line number Diff line change
Expand Up @@ -1937,25 +1937,34 @@ def test_string(self):
""")

self.check_tokenize('f"abc"', """\
STRING 'f"abc"' (1, 0) (1, 6)
FSTRING_START 'f"' (1, 0) (1, 2)
FSTRING_END 'abc' (1, 2) (1, 5)
""")

self.check_tokenize('fR"a{b}c"', """\
STRING 'fR"a{b}c"' (1, 0) (1, 9)
FSTRING_START 'fR"' (1, 0) (1, 3)
FSTRING_MIDDLE 'a' (1, 3) (1, 4)
LBRACE '{' (1, 4) (1, 5)
NAME 'b' (1, 5) (1, 6)
RBRACE '}' (1, 6) (1, 7)
FSTRING_END 'c' (1, 7) (1, 8)
""")

self.check_tokenize('f"""abc"""', """\
STRING 'f\"\"\"abc\"\"\"' (1, 0) (1, 10)
FSTRING_START 'f\"""' (1, 0) (1, 4)
FSTRING_END 'abc' (1, 4) (1, 7)
""")

self.check_tokenize(r'f"abc\
def"', """\
STRING 'f"abc\\\\\\ndef"' (1, 0) (2, 4)
FSTRING_START \'f"\' (1, 0) (1, 2)
FSTRING_END 'abc\\\\\\ndef' (1, 2) (2, 3)
""")

self.check_tokenize(r'Rf"abc\
def"', """\
STRING 'Rf"abc\\\\\\ndef"' (1, 0) (2, 4)
FSTRING_START 'Rf"' (1, 0) (1, 3)
FSTRING_END 'abc\\\\\\ndef' (1, 3) (2, 3)
""")

def test_function(self):
Expand Down

0 comments on commit 081f5a2

Please sign in to comment.