Skip to content

Commit 5a86327

Browse files
committed
Update test_tstring
1 parent 67fdc0f commit 5a86327

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

Lib/test/test_tstring.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ def test_conversions(self):
106106
self.assertTStringEqual(t, ("ASCII: ", ""), [(text, "text", "a")])
107107
self.assertEqual(fstring(t), f"ASCII: {ascii(text)}")
108108

109+
# Test !R conversion (repr)
110+
t = t"Data: {obj!R}"
111+
self.assertTStringEqual(t, ("Data: ", ""), [(obj, "obj", "R")])
112+
self.assertEqual(fstring(t), f"Data: {repr(obj)}")
113+
109114
# Test !z conversion (error)
110115
num = 1
111116
with self.assertRaises(SyntaxError):
@@ -305,11 +310,11 @@ def test_syntax_errors(self):
305310
("t'{x!}'", "t-string: missing conversion character"),
306311
("t'{x=!}'", "t-string: missing conversion character"),
307312
("t'{x!z}'", "t-string: invalid conversion character 'z': "
308-
"expected 's', 'r', or 'a'"),
313+
"expected 's', 'r', 'R', or 'a'"),
309314
("f\"{t'{x!z}'}\"", "t-string: invalid conversion character 'z': "
310-
"expected 's', 'r', or 'a'"),
315+
"expected 's', 'r', 'R', or 'a'"),
311316
("t'{f\"{x!z}\"}'", "f-string: invalid conversion character 'z': "
312-
"expected 's', 'r', or 'a'"),
317+
"expected 's', 'r', 'R', or 'a'"),
313318
("t'{lambda:1}'", "t-string: lambda expressions are not allowed "
314319
"without parentheses"),
315320
("t'{x:{;}}'", "t-string: expecting a valid expression after '{'"),

0 commit comments

Comments
 (0)