aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_fstring.py
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2025-01-22 16:24:54 +0000
committerGitHub <noreply@github.com>2025-01-22 16:24:54 +0000
commit60a3a0dd6fe140fdc87f6e769ee5bb17d92efe4e (patch)
treecb71d3f3975521c3b08c59432916384cf7d90e4c /Lib/test/test_fstring.py
parentba9a4b621577b92f36d88388cc9f791c2dc7d7ba (diff)
downloadcpython-60a3a0dd6fe140fdc87f6e769ee5bb17d92efe4e.tar.gz
cpython-60a3a0dd6fe140fdc87f6e769ee5bb17d92efe4e.zip
gh-124363: Treat debug expressions in f-string as raw strings (#128399)
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_fstring.py')
-rw-r--r--Lib/test/test_fstring.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_fstring.py b/Lib/test/test_fstring.py
index 31d91215889..1d96b7a2c24 100644
--- a/Lib/test/test_fstring.py
+++ b/Lib/test/test_fstring.py
@@ -1649,6 +1649,14 @@ x = (
#self.assertEqual(f'X{x =}Y', 'Xx\t='+repr(x)+'Y')
#self.assertEqual(f'X{x = }Y', 'Xx\t=\t'+repr(x)+'Y')
+ def test_debug_expressions_are_raw_strings(self):
+
+ self.assertEqual(f'{b"\N{OX}"=}', 'b"\\N{OX}"=b\'\\\\N{OX}\'')
+ self.assertEqual(f'{r"\xff"=}', 'r"\\xff"=\'\\\\xff\'')
+ self.assertEqual(f'{r"\n"=}', 'r"\\n"=\'\\\\n\'')
+ self.assertEqual(f"{'\''=}", "'\\''=\"'\"")
+ self.assertEqual(f'{'\xc5'=}', r"'\xc5'='Å'")
+
def test_walrus(self):
x = 20
# This isn't an assignment expression, it's 'x', with a format