File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 8
8
import os
9
9
import os .path
10
10
import pathlib
11
+ import py_compile
11
12
import re
12
13
13
14
import pytest
@@ -105,7 +106,7 @@ def test_directory_without_main(self):
105
106
class RunPycFileTest (CoverageTest ):
106
107
"""Test cases for `run_python_file`."""
107
108
108
- def make_pyc (self ):
109
+ def make_pyc (self , ** kwargs ):
109
110
"""Create a .pyc file, and return the path to it."""
110
111
if env .JYTHON :
111
112
pytest .skip ("Can't make .pyc files on Jython" )
@@ -116,7 +117,7 @@ def doit():
116
117
117
118
doit()
118
119
""" )
119
- compileall .compile_dir ("." , quiet = True )
120
+ compileall .compile_dir ("." , quiet = True , ** kwargs )
120
121
os .remove ("compiled.py" )
121
122
122
123
# Find the .pyc file!
@@ -149,6 +150,12 @@ def test_running_pyc_from_wrong_python(self):
149
150
# In some environments, the pycfile persists and pollutes another test.
150
151
os .remove (pycfile )
151
152
153
+ @pytest .mark .skipif (not env .PYBEHAVIOR .hashed_pyc_pep552 , reason = "No hashed .pyc here" )
154
+ def test_running_hashed_pyc (self ):
155
+ pycfile = self .make_pyc (invalidation_mode = py_compile .PycInvalidationMode .CHECKED_HASH )
156
+ run_python_file ([pycfile ])
157
+ assert self .stdout () == "I am here!\n "
158
+
152
159
def test_no_such_pyc_file (self ):
153
160
path = python_reported_file ('xyzzy.pyc' )
154
161
msg = re .escape (f"No file to run: '{ path } '" )
You can’t perform that action at this time.
0 commit comments