[Python-checkins] cpython (3.1): Fix test_build_py when sys.dont_write_bytecode is true (#9831).

eric.araujo python-checkins at python.org
Sun May 29 18:14:20 CEST 2011


http://hg.python.org/cpython/rev/3d56e559ffc6
changeset: 70483:3d56e559ffc6
branch: 3.1
user: Éric Araujo <merwok at netwok.org>
date: Sat May 28 23:32:50 2011 +0200
summary:
 Fix test_build_py when sys.dont_write_bytecode is true (#9831).
The tests now pass all combinations of -O/-OO and -B. See also #7071
and #6292 for previous variations on the same theme.
test_versionpredicate needs a skip when sys.flags.optimize is true, but
I don’t know how to make that work with a DocTestSuite.
files:
 Lib/distutils/tests/test_build_py.py | 14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
--- a/Lib/distutils/tests/test_build_py.py
+++ b/Lib/distutils/tests/test_build_py.py
@@ -57,11 +57,15 @@
 self.assertEqual(len(cmd.get_outputs()), 3)
 pkgdest = os.path.join(destination, "pkg")
 files = os.listdir(pkgdest)
- self.assertTrue("__init__.py" in files)
- self.assertTrue("__init__.pyc" in files)
- self.assertTrue("README.txt" in files)
+ self.assertIn("__init__.py", files)
+ self.assertIn("README.txt", files)
+ # XXX even with -O, distutils writes pyc, not pyo; bug?
+ if sys.dont_write_bytecode:
+ self.assertNotIn("__init__.pyc", files)
+ else:
+ self.assertIn("__init__.pyc", files)
 
- def test_empty_package_dir (self):
+ def test_empty_package_dir(self):
 # See SF 1668596/1720897.
 cwd = os.getcwd()
 
@@ -109,7 +113,7 @@
 finally:
 sys.dont_write_bytecode = old_dont_write_bytecode
 
- self.assertTrue('byte-compiling is disabled' in self.logs[0][1])
+ self.assertIn('byte-compiling is disabled', self.logs[0][1])
 
 def test_suite():
 return unittest.makeSuite(BuildPyTestCase)
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /