summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-05-28 21:21:19 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-05-28 21:21:19 (GMT)
commitbe778313758ac41682b4d97b91097c57ca354a22 (patch)
treeee5782fe2eae2d83c1b7db41a3b4bf8075687da3 /Lib/distutils/tests
parent1e94021ea59bfdefc03c6af405fd18d64a789d71 (diff)
downloadcpython-be778313758ac41682b4d97b91097c57ca354a22.zip
cpython-be778313758ac41682b4d97b91097c57ca354a22.tar.gz
cpython-be778313758ac41682b4d97b91097c57ca354a22.tar.bz2
Fix test_distutils 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.
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_build_py.py27
1 files changed, 11 insertions, 16 deletions
diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
index 937fa0c..6c6ec20 100644
--- a/Lib/distutils/tests/test_build_py.py
+++ b/Lib/distutils/tests/test_build_py.py
@@ -17,7 +17,7 @@ class BuildPyTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
- def _setup_package_data(self):
+ def test_package_data(self):
sources = self.mkdtemp()
f = open(os.path.join(sources, "__init__.py"), "w")
try:
@@ -57,20 +57,15 @@ class BuildPyTestCase(support.TempdirManager,
self.assertEqual(len(cmd.get_outputs()), 3)
pkgdest = os.path.join(destination, "pkg")
files = os.listdir(pkgdest)
- return files
-
- def test_package_data(self):
- files = self._setup_package_data()
- self.assertTrue("__init__.py" in files)
- self.assertTrue("README.txt" in files)
-
- @unittest.skipIf(sys.flags.optimize >= 2,
- "pyc files are not written with -O2 and above")
- def test_package_data_pyc(self):
- files = self._setup_package_data()
- self.assertTrue("__init__.pyc" in files)
-
- def test_empty_package_dir (self):
+ 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):
# See SF 1668596/1720897.
cwd = os.getcwd()
@@ -118,7 +113,7 @@ class BuildPyTestCase(support.TempdirManager,
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)