Author: Manuel Jacob <[email protected]>
Branch:
Changeset: r82493:423372b7d89b
Date: 2016-02-25 10:23 +0100
http://bitbucket.org/pypy/pypy/changeset/423372b7d89b/
Log: Add app level tests for sys.dont_write_bytecode.
diff --git a/pypy/module/imp/test/test_import.py
b/pypy/module/imp/test/test_import.py
--- a/pypy/module/imp/test/test_import.py
+++ b/pypy/module/imp/test/test_import.py
@@ -98,6 +98,10 @@
'a=5\nb=6\rc="""hello\r\nworld"""\r', mode='wb')
p.join('mod.py').write(
'a=15\nb=16\rc="""foo\r\nbar"""\r', mode='wb')
+ setuppkg("test_bytecode",
+ a = '',
+ b = '',
+ c = '')
# create compiled/x.py and a corresponding pyc file
p = setuppkg("compiled", x = "x = 84")
@@ -1342,6 +1346,36 @@
assert isinstance(importer, zipimport.zipimporter)
+class AppTestWriteBytecode(object):
+ def setup(cls):
+ cls.saved_modules = _setup(cls.space)
+
+ def teardown(cls):
+ _teardown(cls.space, cls.saved_modules)
+
+ def test_default(self):
+ import os.path
+ from test_bytecode import a
+ assert a.__file__.endswith('a.py')
+ assert os.path.exists(a.__file__ + 'c')
+
+ def test_write_bytecode(self):
+ import os.path
+ import sys
+ sys.dont_write_bytecode = False
+ from test_bytecode import b
+ assert b.__file__.endswith('b.py')
+ assert os.path.exists(b.__file__ + 'c')
+
+ def test_dont_write_bytecode(self):
+ import os.path
+ import sys
+ sys.dont_write_bytecode = True
+ from test_bytecode import c
+ assert c.__file__.endswith('c.py')
+ assert not os.path.exists(c.__file__ + 'c')
+
+
class AppTestNoPycFile(object):
spaceconfig = {
"objspace.usepycfiles": False,
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit