summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/tests
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r--Lib/distutils/tests/test_build_py.py16
-rw-r--r--Lib/distutils/tests/test_install_lib.py17
-rw-r--r--Lib/distutils/tests/test_util.py18
3 files changed, 46 insertions, 5 deletions
diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
index 8ad3bbc..582f246 100644
--- a/Lib/distutils/tests/test_build_py.py
+++ b/Lib/distutils/tests/test_build_py.py
@@ -89,6 +89,22 @@ class BuildPyTestCase(support.TempdirManager,
os.chdir(cwd)
sys.stdout = sys.__stdout__
+ def test_dont_write_bytecode(self):
+ # makes sure byte_compile is not used
+ pkg_dir, dist = self.create_dist()
+ cmd = build_py(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(BuildPyTestCase)
diff --git a/Lib/distutils/tests/test_install_lib.py b/Lib/distutils/tests/test_install_lib.py
index b2185b8..99a6d90 100644
--- a/Lib/distutils/tests/test_install_lib.py
+++ b/Lib/distutils/tests/test_install_lib.py
@@ -31,6 +31,8 @@ class InstallLibTestCase(support.TempdirManager,
cmd.finalize_options()
self.assertEquals(cmd.optimize, 2)
+ @unittest.skipUnless(not sys.dont_write_bytecode,
+ 'byte-compile not supported')
def test_byte_compile(self):
pkg_dir, dist = self.create_dist()
cmd = install_lib(dist)
@@ -76,6 +78,21 @@ class InstallLibTestCase(support.TempdirManager,
# get_input should return 2 elements
self.assertEquals(len(cmd.get_inputs()), 2)
+ 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)
diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py
index 8068726..a2f8ed2 100644
--- a/Lib/distutils/tests/test_util.py
+++ b/Lib/distutils/tests/test_util.py
@@ -1,7 +1,4 @@
"""Tests for distutils.util."""
-# not covered yet:
-# - byte_compile
-#
import os
import sys
import unittest
@@ -9,11 +6,12 @@ from copy import copy
from io import BytesIO
import subprocess
-from distutils.errors import DistutilsPlatformError
+from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
from distutils.util import (get_platform, convert_path, change_root,
check_environ, split_quoted, strtobool,
rfc822_escape, get_compiler_versions,
- _find_exe_version, _MAC_OS_X_LD_VERSION)
+ _find_exe_version, _MAC_OS_X_LD_VERSION,
+ byte_compile)
from distutils import util
from distutils.sysconfig import get_config_vars
from distutils import sysconfig
@@ -349,6 +347,16 @@ class UtilTestCase(support.EnvironGuard, unittest.TestCase):
res = get_compiler_versions()
self.assertEquals(res[2], None)
+ 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)