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