summaryrefslogtreecommitdiffstats
path: root/Lib/packaging/tests/test_command_build_py.py
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-10-19 06:18:05 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-10-19 06:18:05 (GMT)
commit4b5a5f7bd5c966648340b8bdbca54e836658cac7 (patch)
tree7ab407c8dbd8540c2db40d8d3a842a73d6eea9a9 /Lib/packaging/tests/test_command_build_py.py
parent8ccd18fff334b9b9a32e9662684f59cac332c524 (diff)
downloadcpython-4b5a5f7bd5c966648340b8bdbca54e836658cac7.zip
cpython-4b5a5f7bd5c966648340b8bdbca54e836658cac7.tar.gz
cpython-4b5a5f7bd5c966648340b8bdbca54e836658cac7.tar.bz2
More fixes for PEP 3147 compliance in packaging (#11254)
Diffstat (limited to 'Lib/packaging/tests/test_command_build_py.py')
-rw-r--r--Lib/packaging/tests/test_command_build_py.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/packaging/tests/test_command_build_py.py b/Lib/packaging/tests/test_command_build_py.py
index a978c91..9d519e3 100644
--- a/Lib/packaging/tests/test_command_build_py.py
+++ b/Lib/packaging/tests/test_command_build_py.py
@@ -102,6 +102,40 @@ class BuildPyTestCase(support.TempdirManager,
os.chdir(cwd)
sys.stdout = old_stdout
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ def test_byte_compile(self):
+ project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
+ os.chdir(project_dir)
+ self.write_file('boiledeggs.py', 'import antigravity')
+ cmd = build_py(dist)
+ cmd.compile = True
+ cmd.build_lib = 'here'
+ cmd.finalize_options()
+ cmd.run()
+
+ found = os.listdir(cmd.build_lib)
+ self.assertEqual(sorted(found), ['__pycache__', 'boiledeggs.py'])
+ found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
+ self.assertEqual(found, ['boiledeggs.%s.pyc' % imp.get_tag()])
+
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ def test_byte_compile_optimized(self):
+ project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
+ os.chdir(project_dir)
+ self.write_file('boiledeggs.py', 'import antigravity')
+ cmd = build_py(dist)
+ cmd.compile = True
+ cmd.optimize = 1
+ cmd.build_lib = 'here'
+ cmd.finalize_options()
+ cmd.run()
+
+ found = os.listdir(cmd.build_lib)
+ self.assertEqual(sorted(found), ['__pycache__', 'boiledeggs.py'])
+ found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
+ self.assertEqual(sorted(found), ['boiledeggs.%s.pyc' % imp.get_tag(),
+ 'boiledeggs.%s.pyo' % imp.get_tag()])
+
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
pkg_dir, dist = self.create_dist()
@@ -118,6 +152,7 @@ class BuildPyTestCase(support.TempdirManager,
self.assertIn('byte-compiling is disabled', self.get_logs()[0])
+
def test_suite():
return unittest.makeSuite(BuildPyTestCase)