@@ -631,6 +631,14 @@ def test_pyobject_bytes_from_null(self):
631
631
s = _testcapi .pyobject_bytes_from_null ()
632
632
self .assertEqual (s , b'<NULL>' )
633
633
634
+ def test_Py_CompileString (self ):
635
+ # Check that Py_CompileString respects the coding cookie
636
+ _compile = _testcapi .Py_CompileString
637
+ code = b"# -*- coding: latin1 -*-\n print('\xc2 \xa4 ')\n "
638
+ result = _compile (code )
639
+ expected = compile (code , "<string>" , "exec" )
640
+ self .assertEqual (result .co_consts , expected .co_consts )
641
+
634
642
635
643
class TestPendingCalls (unittest .TestCase ):
636
644
@@ -1013,14 +1021,6 @@ def test_state_access(self):
1013
1021
with self .assertRaises (TypeError ):
1014
1022
increment_count (1 , 2 , 3 )
1015
1023
1016
- def test_Py_CompileString (self ):
1017
- # Check that Py_CompileString respects the coding cookie
1018
- _compile = _testcapi .Py_CompileString
1019
- code = b"# -*- coding: latin1 -*-\n print('\xc2 \xa4 ')\n "
1020
- result = _compile (code )
1021
- expected = compile (code , "<string>" , "exec" )
1022
- self .assertEqual (result .co_consts , expected .co_consts )
1023
-
1024
1024
1025
1025
if __name__ == "__main__" :
1026
1026
unittest .main ()
0 commit comments