diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2021-11-22 13:04:46 -0500 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2021-11-22 13:05:01 -0500 |
| commit | dd5a2cec373ffe7eefc087c1cd06fb4e491a7e88 (patch) | |
| tree | 7fcee8db024e57bdb088d84caf7ba88c0fd44dee /setuptools/_distutils/tests | |
| parent | 413357393b74acd7f8bd02075a0f7ce8c239b869 (diff) | |
| parent | bfef955b66dc59004b5f33dcc943b983e21be48f (diff) | |
| download | python-setuptools-git-dd5a2cec373ffe7eefc087c1cd06fb4e491a7e88.tar.gz | |
Merge pull request 2902.
Diffstat (limited to 'setuptools/_distutils/tests')
| -rw-r--r-- | setuptools/_distutils/tests/test_core.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/setuptools/_distutils/tests/test_core.py b/setuptools/_distutils/tests/test_core.py index 666ff4a3..d99cfd26 100644 --- a/setuptools/_distutils/tests/test_core.py +++ b/setuptools/_distutils/tests/test_core.py @@ -10,6 +10,7 @@ from . import py38compat as os_helper import unittest from distutils.tests import support from distutils import log +from distutils.dist import Distribution # setup script that uses __file__ setup_using___file__ = """\ @@ -45,6 +46,16 @@ class install(_install): setup(cmdclass={'install': install}) """ +setup_within_if_main = """\ +from distutils.core import setup + +def main(): + return setup(name="setup_within_if_main") + +if __name__ == "__main__": + main() +""" + class CoreTestCase(support.EnvironGuard, unittest.TestCase): def setUp(self): @@ -115,6 +126,20 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase): output = output[:-1] self.assertEqual(cwd, output) + def test_run_setup_within_if_main(self): + dist = distutils.core.run_setup( + self.write_setup(setup_within_if_main), stop_after="config") + self.assertIsInstance(dist, Distribution) + self.assertEqual(dist.get_name(), "setup_within_if_main") + + def test_run_commands(self): + sys.argv = ['setup.py', 'build'] + dist = distutils.core.run_setup( + self.write_setup(setup_within_if_main), stop_after="commandline") + self.assertNotIn('build', dist.have_run) + distutils.core.run_commands(dist) + self.assertIn('build', dist.have_run) + def test_debug_mode(self): # this covers the code called when DEBUG is set sys.argv = ['setup.py', '--name'] |
