mirror of https://github.com/python/cpython.git
Fix broken test and replace redundant generator with a tuple
This commit is contained in:
parent
c71b4c7198
commit
62b4136277
|
@ -20,16 +20,15 @@
|
||||||
from test import script_helper
|
from test import script_helper
|
||||||
|
|
||||||
|
|
||||||
def _iter_files(name):
|
def _files(name):
|
||||||
for f in (name + os.extsep + "py",
|
return (name + os.extsep + "py",
|
||||||
name + os.extsep + "pyc",
|
name + os.extsep + "pyc",
|
||||||
name + os.extsep + "pyo",
|
name + os.extsep + "pyo",
|
||||||
name + os.extsep + "pyw",
|
name + os.extsep + "pyw",
|
||||||
name + "$py.class"):
|
name + "$py.class")
|
||||||
yield f
|
|
||||||
|
|
||||||
def chmod_files(name):
|
def chmod_files(name):
|
||||||
for f in _iter_files(name):
|
for f in _files(name):
|
||||||
try:
|
try:
|
||||||
os.chmod(f, 0o600)
|
os.chmod(f, 0o600)
|
||||||
except OSError as exc:
|
except OSError as exc:
|
||||||
|
@ -37,7 +36,7 @@ def chmod_files(name):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def remove_files(name):
|
def remove_files(name):
|
||||||
for f in _iter_files(name):
|
for f in _files(name):
|
||||||
unlink(f)
|
unlink(f)
|
||||||
rmtree('__pycache__')
|
rmtree('__pycache__')
|
||||||
|
|
||||||
|
@ -160,6 +159,11 @@ def test_rewrite_pyc_with_read_only_source(self):
|
||||||
# Now delete the source file and check the pyc was rewritten
|
# Now delete the source file and check the pyc was rewritten
|
||||||
unlink(fname)
|
unlink(fname)
|
||||||
unload(TESTFN)
|
unload(TESTFN)
|
||||||
|
if __debug__:
|
||||||
|
bytecode_name = fname + "c"
|
||||||
|
else:
|
||||||
|
bytecode_name = fname + "o"
|
||||||
|
os.rename(imp.cache_from_source(fname), bytecode_name)
|
||||||
m3 = __import__(TESTFN)
|
m3 = __import__(TESTFN)
|
||||||
self.assertEqual(m3.x, 'rewritten')
|
self.assertEqual(m3.x, 'rewritten')
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue