summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-10-19 14:03:46 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-10-19 14:03:46 (GMT)
commit62b4136277e42ab7523c4c74e0033c59ad363d2b (patch)
tree22caac0c2386443ce0e373d4f96351be78d001a1 /Lib/test
parentc71b4c7198703e54d9a7377edcdbac9b62eed487 (diff)
downloadcpython-62b4136277e42ab7523c4c74e0033c59ad363d2b.zip
cpython-62b4136277e42ab7523c4c74e0033c59ad363d2b.tar.gz
cpython-62b4136277e42ab7523c4c74e0033c59ad363d2b.tar.bz2
Fix broken test and replace redundant generator with a tuple
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_import.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index bffb1df..b10f350 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -20,16 +20,15 @@ from test.support import (
from test import script_helper
-def _iter_files(name):
- for f in (name + os.extsep + "py",
- name + os.extsep + "pyc",
- name + os.extsep + "pyo",
- name + os.extsep + "pyw",
- name + "$py.class"):
- yield f
+def _files(name):
+ return (name + os.extsep + "py",
+ name + os.extsep + "pyc",
+ name + os.extsep + "pyo",
+ name + os.extsep + "pyw",
+ name + "$py.class")
def chmod_files(name):
- for f in _iter_files(name):
+ for f in _files(name):
try:
os.chmod(f, 0o600)
except OSError as exc:
@@ -37,7 +36,7 @@ def chmod_files(name):
raise
def remove_files(name):
- for f in _iter_files(name):
+ for f in _files(name):
unlink(f)
rmtree('__pycache__')
@@ -160,6 +159,11 @@ class ImportTests(unittest.TestCase):
# Now delete the source file and check the pyc was rewritten
unlink(fname)
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)
self.assertEqual(m3.x, 'rewritten')
finally: