Skip to content

Commit e6d23e7

Browse files
committed
test_fstring test using script
1 parent a13aaea commit e6d23e7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Lib/test/test_fstring.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@
1212
import dis
1313
import os
1414
import re
15-
import tokenize
1615
import types
1716
import decimal
1817
import unittest
1918
import warnings
20-
from io import BytesIO
2119
from test import support
2220
from test.support.os_helper import temp_cwd
2321
from test.support.script_helper import assert_python_failure, assert_python_ok
@@ -1862,10 +1860,11 @@ def __format__(self, format):
18621860
self.assertEqual(rf"{UnchangedFormat():\xFF} {UnchangedFormat():\n}", '\\xFF \\n')
18631861

18641862
def test_gh139516(self):
1865-
# gh-139516
1866-
# The '\n' is explicit to ensure no trailing whitespace which would invalidate the test.
1867-
# Must use tokenize instead of compile so that source is parsed by line which exposes the bug.
1868-
list(tokenize.tokenize(BytesIO('''f"{f(a=lambda: 'à'\n)}"'''.encode()).readline))
1863+
with temp_cwd():
1864+
script = 'script.py'
1865+
with open(script, 'wb') as f:
1866+
f.write('''def f(a): pass\nf"{f(a=lambda: 'à'\n)}"'''.encode())
1867+
assert_python_ok(script)
18691868

18701869

18711870
if __name__ == '__main__':

0 commit comments

Comments
 (0)