Skip to content

Commit

Permalink
test: simplify pyc logic
Browse files Browse the repository at this point in the history
The old pycache_prefix logic was because we would run tests in Docker
containers, and they went faster if we set PYTHONCACHEPREFIX.  But we
don't do that anymore, so we can use simpler code.
  • Loading branch information
nedbat committed Aug 9, 2021
1 parent 15945f2 commit f5621ba
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions tests/test_execfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import os
import os.path
import pathlib
import re
import sys

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f5621ba

Please sign in to comment.