diff options
Diffstat (limited to 'Lib/distutils/tests')
-rw-r--r-- | Lib/distutils/tests/support.py | 8 | ||||
-rw-r--r-- | Lib/distutils/tests/test_build_py.py | 35 |
2 files changed, 39 insertions, 4 deletions
diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py index 475ceee..91e704c 100644 --- a/Lib/distutils/tests/support.py +++ b/Lib/distutils/tests/support.py @@ -9,12 +9,12 @@ from distutils import log class LoggingSilencer(object): def setUp(self): - super(LoggingSilencer, self).setUp() + super().setUp() self.threshold = log.set_threshold(log.FATAL) def tearDown(self): log.set_threshold(self.threshold) - super(LoggingSilencer, self).tearDown() + super().tearDown() class TempdirManager(object): @@ -24,11 +24,11 @@ class TempdirManager(object): """ def setUp(self): - super(TempdirManager, self).setUp() + super().setUp() self.tempdirs = [] def tearDown(self): - super(TempdirManager, self).tearDown() + super().tearDown() while self.tempdirs: d = self.tempdirs.pop() shutil.rmtree(d) diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py index 78e4c55..54a4ed8 100644 --- a/Lib/distutils/tests/test_build_py.py +++ b/Lib/distutils/tests/test_build_py.py @@ -1,10 +1,13 @@ """Tests for distutils.command.build_py.""" import os +import sys +import StringIO import unittest from distutils.command.build_py import build_py from distutils.core import Distribution +from distutils.errors import DistutilsFileError from distutils.tests import support @@ -53,6 +56,38 @@ class BuildPyTestCase(support.TempdirManager, self.assert_("__init__.pyc" in files) self.assert_("README.txt" in files) + def test_empty_package_dir (self): + # See SF 1668596/1720897. + cwd = os.getcwd() + + # create the distribution files. + sources = self.mkdtemp() + open(os.path.join(sources, "__init__.py"), "w").close() + + testdir = os.path.join(sources, "doc") + os.mkdir(testdir) + open(os.path.join(testdir, "testfile"), "w").close() + + os.chdir(sources) + sys.stdout = StringIO.StringIO() + + try: + dist = Distribution({"packages": ["pkg"], + "package_dir": {"pkg": ""}, + "package_data": {"pkg": ["doc/*"]}}) + # script_name need not exist, it just need to be initialized + dist.script_name = os.path.join(sources, "setup.py") + dist.script_args = ["build"] + dist.parse_command_line() + + try: + dist.run_commands() + except DistutilsFileError: + self.fail("failed package_data test when package_dir is ''") + finally: + # Restore state. + os.chdir(cwd) + sys.stdout = sys.__stdout__ def test_suite(): return unittest.makeSuite(BuildPyTestCase) |