[Python-checkins] cpython: Fix format of warnings from the packaging check command

eric.araujo python-checkins at python.org
Thu Jun 2 16:43:47 CEST 2011


http://hg.python.org/cpython/rev/31727f819caf
changeset:   70605:31727f819caf
user:        Éric Araujo <merwok at netwok.org>
date:        Thu Jun 02 14:54:44 2011 +0200
summary:
  Fix format of warnings from the packaging check command

files:
  Lib/packaging/command/check.py            |   2 +-
  Lib/packaging/tests/test_command_check.py |  11 +++++++++++
  2 files changed, 12 insertions(+), 1 deletions(-)


diff --git a/Lib/packaging/command/check.py b/Lib/packaging/command/check.py
--- a/Lib/packaging/command/check.py
+++ b/Lib/packaging/command/check.py
@@ -32,7 +32,7 @@
         # XXX we could use a special handler for this, but would need to test
         # if it works even if the logger has a too high level
         self._warnings.append((msg, args))
-        return logger.warning(self.get_command_name() + msg, *args)
+        return logger.warning('%s: %s' % (self.get_command_name(), msg), *args)
 
     def run(self):
         """Runs the command."""
diff --git a/Lib/packaging/tests/test_command_check.py b/Lib/packaging/tests/test_command_check.py
--- a/Lib/packaging/tests/test_command_check.py
+++ b/Lib/packaging/tests/test_command_check.py
@@ -124,6 +124,17 @@
         cmd.check_hooks_resolvable()
         self.assertEqual(len(self.get_logs(logging.WARNING)), 1)
 
+    def test_warn(self):
+        _, dist = self.create_dist()
+        cmd = check(dist)
+        self.assertEqual([], self.get_logs())
+        cmd.warn('hello')
+        self.assertEqual(['check: hello'], self.get_logs())
+        cmd.warn('hello %s', 'world')
+        self.assertEqual(['check: hello world'], self.get_logs())
+        cmd.warn('hello %s %s', 'beautiful', 'world')
+        self.assertEqual(['check: hello beautiful world'], self.get_logs())
+
 
 def test_suite():
     return unittest.makeSuite(CheckTestCase)

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list