@@ -55,6 +55,24 @@ def test_issue7820(self):
5555 # two bytes in common with the UTF-8 BOM
5656 self .assertRaises (SyntaxError , eval , b'\xef \xbb \x20 ' )
5757
58+ def test_error_message (self ):
59+ compile (b'# -*- coding: iso-8859-15 -*-\n ' , 'dummy' , 'exec' )
60+ compile (b'\xef \xbb \xbf \n ' , 'dummy' , 'exec' )
61+ compile (b'\xef \xbb \xbf # -*- coding: utf-8 -*-\n ' , 'dummy' , 'exec' )
62+ with self .assertRaisesRegexp (SyntaxError , 'fake' ):
63+ compile (b'# -*- coding: fake -*-\n ' , 'dummy' , 'exec' )
64+ with self .assertRaisesRegexp (SyntaxError , 'iso-8859-15' ):
65+ compile (b'\xef \xbb \xbf # -*- coding: iso-8859-15 -*-\n ' ,
66+ 'dummy' , 'exec' )
67+ with self .assertRaisesRegexp (SyntaxError , 'BOM' ):
68+ compile (b'\xef \xbb \xbf # -*- coding: iso-8859-15 -*-\n ' ,
69+ 'dummy' , 'exec' )
70+ with self .assertRaisesRegexp (SyntaxError , 'fake' ):
71+ compile (b'\xef \xbb \xbf # -*- coding: fake -*-\n ' , 'dummy' , 'exec' )
72+ with self .assertRaisesRegexp (SyntaxError , 'BOM' ):
73+ compile (b'\xef \xbb \xbf # -*- coding: fake -*-\n ' , 'dummy' , 'exec' )
74+
75+
5876def test_main ():
5977 support .run_unittest (PEP263Test )
6078
0 commit comments