diff options
| author | Konrad Delong <konryd@gmail.com> | 2010-07-27 15:06:44 +0200 |
|---|---|---|
| committer | Konrad Delong <konryd@gmail.com> | 2010-07-27 15:06:44 +0200 |
| commit | 6b554ce70cd2e6b7a6e0633100de6cb533e46d46 (patch) | |
| tree | 86c0cf2249571b3db5f2735d8f1542a8ee0853e5 /src/distutils2 | |
| parent | 462f1aa669f88e31a24fbb67329718e267cb7672 (diff) | |
| download | disutils2-6b554ce70cd2e6b7a6e0633100de6cb533e46d46.tar.gz | |
emitting warnings instead of installing distributions from option
Diffstat (limited to 'src/distutils2')
| -rw-r--r-- | src/distutils2/command/test.py | 7 | ||||
| -rw-r--r-- | src/distutils2/dist.py | 2 | ||||
| -rw-r--r-- | src/distutils2/tests/test_test.py | 16 | ||||
| -rw-r--r-- | src/distutils2/tests/with_support.py | 7 |
4 files changed, 30 insertions, 2 deletions
diff --git a/src/distutils2/command/test.py b/src/distutils2/command/test.py index 043f22c..8bbaac2 100644 --- a/src/distutils2/command/test.py +++ b/src/distutils2/command/test.py @@ -1,6 +1,8 @@ import os, sys from distutils2.core import Command +from distutils2._backport.pkgutil import get_distribution import unittest +import warnings def get_loader_instance(dotted_path): if dotted_path is None: @@ -38,6 +40,11 @@ class test(Command): def finalize_options(self): self.build_lib = self.get_finalized_command("build").build_lib + if self.distribution.tests_require: + for requirement in self.distribution.tests_require: + if get_distribution(requirement) is None: + warnings.warn("The test dependency %s is not installed which may couse the tests to fail.", + RuntimeWarning) def run(self): prev_cwd = os.getcwd() diff --git a/src/distutils2/dist.py b/src/distutils2/dist.py index 052d007..98e8cf1 100644 --- a/src/distutils2/dist.py +++ b/src/distutils2/dist.py @@ -109,6 +109,8 @@ Common commands: (see '--help-commands' for more) "print the list of packages/modules provided"), ('requires', None, "print the list of packages/modules required"), + ('tests-require', None, + "print the list of packages/modules required to run the test suite"), ('obsoletes', None, "print the list of packages/modules made obsolete") ] diff --git a/src/distutils2/tests/test_test.py b/src/distutils2/tests/test_test.py index 7159af6..da60d92 100644 --- a/src/distutils2/tests/test_test.py +++ b/src/distutils2/tests/test_test.py @@ -4,6 +4,7 @@ from os.path import join from StringIO import StringIO from distutils2.tests.support import unittest, TempdirManager from distutils2.command.test import test +from distutils2.dist import Distribution import subprocess try: @@ -83,8 +84,19 @@ class TestTest(TempdirManager, unittest.TestCase): def _test_works_with_2to3(self): pass - def _test_downloads_test_requires(self): - pass + @unittest.skipUnless(sys.version > '2.6', 'Need >= 2.6') + def test_checks_requires(self): + from distutils2.tests.with_support import examine_warnings + dist = Distribution() + dist.tests_require = ['ohno_ohno-impossible_1234-name_stop-that!'] + cmd = test(dist) + def examinator(ws): + cmd.ensure_finalized() + self.assertEqual(1, len(ws)) + warning = ws[0] + self.assertIs(warning.category, RuntimeWarning) + + examine_warnings(examinator) def test_suite(): return unittest.makeSuite(TestTest) diff --git a/src/distutils2/tests/with_support.py b/src/distutils2/tests/with_support.py new file mode 100644 index 0000000..bca0197 --- /dev/null +++ b/src/distutils2/tests/with_support.py @@ -0,0 +1,7 @@ +def examine_warnings(examinator): + """Given an examinator function calls it as if the code was under with + catch_warnings block. Useful for testing older Python versions""" + import warnings + warnings.simplefilter('default') + with warnings.catch_warnings(record=True) as ws: + examinator(ws) |
