summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_import.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2012-08-24 08:32:40 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2012-08-24 08:32:40 (GMT)
commita508770e20ac709ce9b29198bc5cf336d2e41b96 (patch)
tree9efe19b1599aba38ea7e69314e9f8640e88b05ba /Lib/test/test_import.py
parent36d188c7f7aa9ac19dc0ef075a465c18c59b81a2 (diff)
downloadcpython-a508770e20ac709ce9b29198bc5cf336d2e41b96.zip
cpython-a508770e20ac709ce9b29198bc5cf336d2e41b96.tar.gz
cpython-a508770e20ac709ce9b29198bc5cf336d2e41b96.tar.bz2
Close #2501: Permission bits are once again correctly copied from the source file to the cached bytecode file. Test by Eric Snow.
Diffstat (limited to 'Lib/test/test_import.py')
-rw-r--r--Lib/test/test_import.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index 7f2fad0..60447dc 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -120,12 +120,35 @@ class ImportTests(unittest.TestCase):
s = os.stat(fn)
# Check that the umask is respected, and the executable bits
# aren't set.
- self.assertEqual(stat.S_IMODE(s.st_mode), 0o666 & ~mask)
+ self.assertEqual(oct(stat.S_IMODE(s.st_mode)), oct(0o666 & ~mask))
finally:
del sys.path[0]
remove_files(TESTFN)
unload(TESTFN)
+ @unittest.skipUnless(os.name == 'posix',
+ "test meaningful only on posix systems")
+ def test_cached_mode_issue_2051(self):
+ mode = 0o600
+ source = TESTFN + ".py"
+ with script_helper.temp_dir() as tempdir:
+ path = script_helper.make_script(tempdir, TESTFN,
+ "key='top secret'")
+ os.chmod(path, mode)
+ compiled = imp.cache_from_source(path)
+ sys.path.insert(0, tempdir)
+ try:
+ __import__(TESTFN)
+ finally:
+ sys.path.remove(tempdir)
+
+ if not os.path.exists(compiled):
+ self.fail("__import__ did not result in creation of "
+ "either a .pyc or .pyo file")
+ stat_info = os.stat(compiled)
+
+ self.assertEqual(oct(stat.S_IMODE(stat_info.st_mode)), oct(mode))
+
def test_imp_module(self):
# Verify that the imp module can correctly load and find .py files
# XXX (ncoghlan): It would be nice to use support.CleanImport