(self)
| 231 | eval("t'Hello, {name}'") |
| 232 | |
| 233 | def test_literal_concatenation(self): |
| 234 | # Test concatenation of t-string literals |
| 235 | t = t"Hello, " t"world" |
| 236 | self.assertTStringEqual(t, ("Hello, world",), ()) |
| 237 | self.assertEqual(fstring(t), "Hello, world") |
| 238 | |
| 239 | # Test concatenation with interpolation |
| 240 | name = "Python" |
| 241 | t = t"Hello, " t"{name}" |
| 242 | self.assertTStringEqual(t, ("Hello, ", ""), [(name, "name")]) |
| 243 | self.assertEqual(fstring(t), "Hello, Python") |
| 244 | |
| 245 | # Test disallowed mix of t-string and string/f-string (incl. bytes) |
| 246 | what = 't' |
| 247 | expected_msg = 'cannot mix t-string literals with string or bytes literals' |
| 248 | for case in ( |
| 249 | "t'{what}-string literal' 'str literal'", |
| 250 | "t'{what}-string literal' u'unicode literal'", |
| 251 | "t'{what}-string literal' f'f-string literal'", |
| 252 | "t'{what}-string literal' r'raw string literal'", |
| 253 | "t'{what}-string literal' rf'raw f-string literal'", |
| 254 | "t'{what}-string literal' b'bytes literal'", |
| 255 | "t'{what}-string literal' br'raw bytes literal'", |
| 256 | "'str literal' t'{what}-string literal'", |
| 257 | "u'unicode literal' t'{what}-string literal'", |
| 258 | "f'f-string literal' t'{what}-string literal'", |
| 259 | "r'raw string literal' t'{what}-string literal'", |
| 260 | "rf'raw f-string literal' t'{what}-string literal'", |
| 261 | "b'bytes literal' t'{what}-string literal'", |
| 262 | "br'raw bytes literal' t'{what}-string literal'", |
| 263 | ): |
| 264 | with self.subTest(case): |
| 265 | with self.assertRaisesRegex(SyntaxError, expected_msg): |
| 266 | eval(case) |
| 267 | |
| 268 | def test_triple_quoted(self): |
| 269 | # Test triple-quoted t-strings |
nothing calls this directly
no test coverage detected