@@ -239,45 +239,20 @@ def test_literal_concatenation(self):
239239 self .assertTStringEqual (t , ("Hello, " , "" ), [(name , "name" )])
240240 self .assertEqual (fstring (t ), "Hello, Python" )
241241
242- # Test concatenation with string literal
243- name = "Python"
244- t = t "Hello, {name}" "and welcome!"
245- self .assertTStringEqual (
246- t , ("Hello, " , "and welcome!" ), [(name , "name" )]
247- )
248- self .assertEqual (fstring (t ), "Hello, Pythonand welcome!" )
249-
250- # Test concatenation with Unicode literal
251- name = "Python"
252- t = t "Hello, {name}" u"and welcome!"
253- self .assertTStringEqual (
254- t , ("Hello, " , "and welcome!" ), [(name , "name" )]
255- )
256- self .assertEqual (fstring (t ), "Hello, Pythonand welcome!" )
257-
258- # Test concatenation with f-string literal
259- tab = '\t '
260- t = t "Tab: {tab}. " f"f-tab: { tab } ."
261- self .assertTStringEqual (t , ("Tab: " , ". f-tab: \t ." ), [(tab , "tab" )])
262- self .assertEqual (fstring (t ), "Tab: \t . f-tab: \t ." )
263-
264- # Test concatenation with raw string literal
265- tab = '\t '
266- t = t "Tab: {tab}. " r"Raw tab: \t."
267- self .assertTStringEqual (
268- t , ("Tab: " , r". Raw tab: \t." ), [(tab , "tab" )]
269- )
270- self .assertEqual (fstring (t ), "Tab: \t . Raw tab: \\ t." )
271-
272- # Test concatenation with raw f-string literal
273- tab = '\t '
274- t = t "Tab: {tab}. " rf"f-tab: { tab } . Raw tab: \t."
275- self .assertTStringEqual (
276- t , ("Tab: " , ". f-tab: \t . Raw tab: \\ t." ), [(tab , "tab" )]
277- )
278- self .assertEqual (fstring (t ), "Tab: \t . f-tab: \t . Raw tab: \\ t." )
279-
242+ # Test disallowed mix of t-string and string
280243 what = 't'
244+ expected_msg = 'cannot mix str and Template literals'
245+ for case in (
246+ "t'{what}-string literal' 'str literal'" ,
247+ "t'{what}-string literal' u'unicode literal'" ,
248+ "t'{what}-string literal' f'f-string literal'" ,
249+ "t'{what}-string literal' r'raw string literal'" ,
250+ "t'{what}-string literal' rf'raw f-string literal'" ,
251+ ):
252+ with self .assertRaisesRegex (SyntaxError , expected_msg ):
253+ eval (case )
254+
255+ # Test disallowed mix of t-string and bytes
281256 expected_msg = 'cannot mix bytes and nonbytes literals'
282257 for case in (
283258 "t'{what}-string literal' b'bytes literal'" ,
0 commit comments