summaryrefslogtreecommitdiff
path: root/tests/test_core.py
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-07-28 15:55:07 +1200
committerRobert Collins <rbtcollins@hp.com>2015-07-28 15:55:07 +1200
commit7c42a077cf4a91e095a2bc4964927de32b5cab78 (patch)
tree1ef7e0e15497918677a5b38e904ea9794e3d4370 /tests/test_core.py
parentb40f57b6fd9345d1f73a667d0b406b2aeb714071 (diff)
downloadpython-setuptools-git-7c42a077cf4a91e095a2bc4964927de32b5cab78.tar.gz
Issue #23426: run_setup was broken in distutils.
Patch from Alexander Belopolsky.
Diffstat (limited to 'tests/test_core.py')
-rw-r--r--tests/test_core.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test_core.py b/tests/test_core.py
index 41321f7d..57856f19 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -28,6 +28,21 @@ from distutils.core import setup
setup()
"""
+setup_does_nothing = """\
+from distutils.core import setup
+setup()
+"""
+
+
+setup_defines_subclass = """\
+from distutils.core import setup
+from distutils.command.install import install as _install
+
+class install(_install):
+ sub_commands = _install.sub_commands + ['cmd']
+
+setup(cmdclass={'install': install})
+"""
class CoreTestCase(support.EnvironGuard, unittest.TestCase):
@@ -65,6 +80,21 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
distutils.core.run_setup(
self.write_setup(setup_using___file__))
+ def test_run_setup_preserves_sys_argv(self):
+ # Make sure run_setup does not clobber sys.argv
+ argv_copy = sys.argv.copy()
+ distutils.core.run_setup(
+ self.write_setup(setup_does_nothing))
+ self.assertEqual(sys.argv, argv_copy)
+
+ def test_run_setup_defines_subclass(self):
+ # Make sure the script can use __file__; if that's missing, the test
+ # setup.py script will raise NameError.
+ dist = distutils.core.run_setup(
+ self.write_setup(setup_defines_subclass))
+ install = dist.get_command_obj('install')
+ self.assertIn('cmd', install.sub_commands)
+
def test_run_setup_uses_current_dir(self):
# This tests that the setup script is run with the current directory
# as its own current directory; this was temporarily broken by a