[Python-checkins] distutils2: changed warning to user announcement

tarek.ziade python-checkins at python.org
Sun Sep 19 10:20:22 CEST 2010


tarek.ziade pushed 4ccf2014eff0 to distutils2:
http://hg.python.org/distutils2/rev/4ccf2014eff0
changeset: 632:4ccf2014eff0
user: Konrad Delong <konryd at gmail.com>
date: Sun Aug 15 11:51:48 2010 +0200
summary: changed warning to user announcement
files: src/distutils2/command/test.py, src/distutils2/tests/test_test.py
diff --git a/src/distutils2/command/test.py b/src/distutils2/command/test.py
--- a/src/distutils2/command/test.py
+++ b/src/distutils2/command/test.py
@@ -1,7 +1,6 @@
 import os
 import sys
 import unittest
-import warnings
 
 from distutils2 import log
 from distutils2.core import Command
@@ -34,10 +33,9 @@
 self.build_lib = self.get_finalized_command("build").build_lib
 for requirement in self.tests_require:
 if get_distribution(requirement) is None:
- warnings.warn("The test dependency %s is not installed which may couse the tests to fail." % requirement,
- RuntimeWarning)
+ self.announce("The test dependency %s is not installed which may couse the tests to fail." % requirement)
 if not self.suite and not self.runner and self.get_ut_with_discovery() is None:
- self.announce("No test discovery available. Please specify the 'suite' or 'runner' option or install unittest2.", log.ERROR)
+ raise DistutilsOptionError("No test discovery available. Please specify the 'suite' or 'runner' option or install unittest2.")
 
 def get_ut_with_discovery(self):
 if hasattr(unittest.TestLoader, "discover"):
diff --git a/src/distutils2/tests/test_test.py b/src/distutils2/tests/test_test.py
--- a/src/distutils2/tests/test_test.py
+++ b/src/distutils2/tests/test_test.py
@@ -3,7 +3,6 @@
 import sys
 import shutil
 import subprocess
-import warnings
 
 from copy import copy
 from os.path import join
@@ -120,14 +119,16 @@
 def _test_works_with_2to3(self):
 pass
 
- @unittest.skipUnless(sys.version > '2.6', 'Need >= 2.6')
 def test_checks_requires(self):
 dist = Distribution()
 cmd = test(dist)
- cmd.tests_require = ['ohno_ohno-impossible_1234-name_stop-that!']
+ phony_project = 'ohno_ohno-impossible_1234-name_stop-that!'
+ cmd.tests_require = [phony_project]
+ record = []
+ cmd.announce = lambda *args: record.append(args)
 cmd.ensure_finalized()
- self.assertEqual(1, len(self.warnings))
- self.assertIs(self.warnings[0]["category"], RuntimeWarning)
+ self.assertEqual(1, len(record))
+ self.assertIn(phony_project, record[0][0])
 
 def test_custom_runner(self):
 dist = Distribution()
--
Repository URL: http://hg.python.org/distutils2


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /