]> granicus.if.org Git - python/commitdiff
added more test coverage from trunk for #7617
authorTarek Ziadé <ziade.tarek@gmail.com>
Fri, 8 Jan 2010 23:54:15 +0000 (23:54 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Fri, 8 Jan 2010 23:54:15 +0000 (23:54 +0000)
Lib/distutils/tests/test_install_lib.py [new file with mode: 0644]
Lib/distutils/tests/test_util.py [new file with mode: 0644]

diff --git a/Lib/distutils/tests/test_install_lib.py b/Lib/distutils/tests/test_install_lib.py
new file mode 100644 (file)
index 0000000..78922f4
--- /dev/null
@@ -0,0 +1,35 @@
+"""Tests for distutils.command.install_data."""
+import sys
+import os
+import unittest
+
+from distutils.command.install_lib import install_lib
+from distutils.extension import Extension
+from distutils.tests import support
+from distutils.errors import DistutilsOptionError
+
+class InstallLibTestCase(support.TempdirManager,
+                         support.LoggingSilencer,
+                         unittest.TestCase):
+
+    def test_dont_write_bytecode(self):
+        # makes sure byte_compile is not used
+        pkg_dir, dist = self.create_dist()
+        cmd = install_lib(dist)
+        cmd.compile = 1
+        cmd.optimize = 1
+
+        old_dont_write_bytecode = sys.dont_write_bytecode
+        sys.dont_write_bytecode = True
+        try:
+            cmd.byte_compile([])
+        finally:
+            sys.dont_write_bytecode = old_dont_write_bytecode
+
+        self.assertTrue('byte-compiling is disabled' in self.logs[0][1])
+
+def test_suite():
+    return unittest.makeSuite(InstallLibTestCase)
+
+if __name__ == "__main__":
+    unittest.main(defaultTest="test_suite")
diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py
new file mode 100644 (file)
index 0000000..981ad00
--- /dev/null
@@ -0,0 +1,24 @@
+"""Tests for distutils.util."""
+import sys
+import unittest
+
+from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
+from distutils.util import byte_compile
+
+class UtilTestCase(unittest.TestCase):
+
+    def test_dont_write_bytecode(self):
+        # makes sure byte_compile raise a DistutilsError
+        # if sys.dont_write_bytecode is True
+        old_dont_write_bytecode = sys.dont_write_bytecode
+        sys.dont_write_bytecode = True
+        try:
+            self.assertRaises(DistutilsByteCompileError, byte_compile, [])
+        finally:
+            sys.dont_write_bytecode = old_dont_write_bytecode
+
+def test_suite():
+    return unittest.makeSuite(UtilTestCase)
+
+if __name__ == "__main__":
+    unittest.main(defaultTest="test_suite")