@@ -236,12 +236,9 @@ def check(test, error=False):
236236 check (f"[{ num } for x in ()]" )
237237 check (f"{ num } spam" , error = True )
238238
239+ with self .assertWarnsRegex (SyntaxWarning , r'invalid \w+ literal' ):
240+ compile (f"{ num } is x" , "<testcase>" , "eval" )
239241 with warnings .catch_warnings ():
240- warnings .filterwarnings ('ignore' , '"is" with a literal' ,
241- SyntaxWarning )
242- with self .assertWarnsRegex (SyntaxWarning ,
243- r'invalid \w+ literal' ):
244- compile (f"{ num } is x" , "<testcase>" , "eval" )
245242 warnings .simplefilter ('error' , SyntaxWarning )
246243 with self .assertRaisesRegex (SyntaxError ,
247244 r'invalid \w+ literal' ):
@@ -1467,21 +1464,33 @@ def test_comparison(self):
14671464 if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in x is x is not x : pass
14681465
14691466 def test_comparison_is_literal (self ):
1470- def check (test , msg = '"is" with a literal' ):
1467+ def check (test , msg ):
14711468 self .check_syntax_warning (test , msg )
14721469
1473- check ('x is 1' )
1474- check ('x is "thing"' )
1475- check ('1 is x' )
1476- check ('x is y is 1' )
1477- check ('x is not 1' , '"is not" with a literal' )
1470+ check ('x is 1' , '"is" with \' int\' literal' )
1471+ check ('x is "thing"' , '"is" with \' str\' literal' )
1472+ check ('1 is x' , '"is" with \' int\' literal' )
1473+ check ('x is y is 1' , '"is" with \' int\' literal' )
1474+ check ('x is not 1' , '"is not" with \' int\' literal' )
1475+ check ('x is not (1, 2)' , '"is not" with \' tuple\' literal' )
1476+ check ('(1, 2) is not x' , '"is not" with \' tuple\' literal' )
1477+
1478+ check ('None is 1' , '"is" with \' int\' literal' )
1479+ check ('1 is None' , '"is" with \' int\' literal' )
1480+
1481+ check ('x == 3 is y' , '"is" with \' int\' literal' )
1482+ check ('x == "thing" is y' , '"is" with \' str\' literal' )
14781483
14791484 with warnings .catch_warnings ():
14801485 warnings .simplefilter ('error' , SyntaxWarning )
14811486 compile ('x is None' , '<testcase>' , 'exec' )
14821487 compile ('x is False' , '<testcase>' , 'exec' )
14831488 compile ('x is True' , '<testcase>' , 'exec' )
14841489 compile ('x is ...' , '<testcase>' , 'exec' )
1490+ compile ('None is x' , '<testcase>' , 'exec' )
1491+ compile ('False is x' , '<testcase>' , 'exec' )
1492+ compile ('True is x' , '<testcase>' , 'exec' )
1493+ compile ('... is x' , '<testcase>' , 'exec' )
14851494
14861495 def test_warn_missed_comma (self ):
14871496 def check (test ):
0 commit comments