diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-12 11:34:19 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2012-11-12 11:34:19 -0500 |
commit | d06463e80c41ef52153e8d500487aa2b07733dda (patch) | |
tree | c3f8d4dfe0099c92a300383fddad091994128b19 | |
parent | eb6d290b8a4b089cd4d71364d38cf702bcb9289b (diff) | |
download | python-coveragepy-git-d06463e80c41ef52153e8d500487aa2b07733dda.tar.gz |
Once you start unit testing setup.py, where do you stop??
-rw-r--r-- | setup.py | 39 | ||||
-rw-r--r-- | test/test_misc.py | 14 |
2 files changed, 35 insertions, 18 deletions
@@ -129,20 +129,25 @@ if sys.version_info >= (3, 0): use_2to3=False, )) -# For a variety of reasons, it might not be possible to install the C -# extension. Try it with, and if it fails, try it without. -try: - setup(**setup_args) -except: # pylint: disable=W0702 - # When setup() can't compile, it tries to exit. We'll catch SystemExit - # here :-(, and try again. - if 'install' not in sys.argv or 'ext_modules' not in setup_args: - # We weren't trying to install an extension, so forget it. - raise - msg = "Couldn't install with extension module, trying without it..." - exc = sys.exc_info()[1] - exc_msg = "%s: %s" % (exc.__class__.__name__, exc) - print("**\n** %s\n** %s\n**" % (msg, exc_msg)) - - del setup_args['ext_modules'] - setup(**setup_args) +def main(): + """Actually invoke setup() with the arguments we built above.""" + # For a variety of reasons, it might not be possible to install the C + # extension. Try it with, and if it fails, try it without. + try: + setup(**setup_args) + except: # pylint: disable=W0702 + # When setup() can't compile, it tries to exit. We'll catch SystemExit + # here :-(, and try again. + if 'install' not in sys.argv or 'ext_modules' not in setup_args: + # We weren't trying to install an extension, so forget it. + raise + msg = "Couldn't install with extension module, trying without it..." + exc = sys.exc_info()[1] + exc_msg = "%s: %s" % (exc.__class__.__name__, exc) + print("**\n** %s\n** %s\n**" % (msg, exc_msg)) + + del setup_args['ext_modules'] + setup(**setup_args) + +if __name__ == '__main__': + main() diff --git a/test/test_misc.py b/test/test_misc.py index 857f4cd8..44607a2d 100644 --- a/test/test_misc.py +++ b/test/test_misc.py @@ -33,7 +33,7 @@ class SetupPyTest(CoverageTest): run_in_temp_dir = False - def test_version(self): + def test_metadata(self): status, output = self.run_command_status( "python setup.py --description --version --url --author" ) @@ -43,3 +43,15 @@ class SetupPyTest(CoverageTest): self.assertEqual(out[1], __version__) self.assertEqual(out[2], __url__) self.assertIn("Ned Batchelder", out[3]) + + def test_more_metadata(self): + from setup import setup_args + + classifiers = setup_args['classifiers'] + self.assertGreater(len(classifiers), 7) + self.assertTrue(classifiers[-1].startswith("Development Status ::")) + + long_description = setup_args['long_description'].splitlines() + self.assertGreater(len(long_description), 7) + self.assertNotEqual(long_description[0].strip(), "") + self.assertNotEqual(long_description[-1].strip(), "") |