diff --git a/tests/test_execfile.py b/tests/test_execfile.py index dcd03b447..fe02f5fe2 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -8,6 +8,7 @@ import json import os import os.path +import pathlib import re import sys @@ -121,15 +122,7 @@ def doit(): os.remove("compiled.py") # Find the .pyc file! - roots = ["."] - prefix = getattr(sys, "pycache_prefix", None) - if prefix: - roots.append(prefix) - for root in roots: # pragma: part covered - for there, _, files in os.walk(root): # pragma: part covered - for fname in files: - if fnmatch.fnmatch(fname, "compiled*.pyc"): - return os.path.join(there, fname) + return str(next(pathlib.Path(".").rglob("compiled*.pyc"))) def test_running_pyc(self): pycfile = self.make_pyc()