]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix format of warnings from the packaging check command
authorÉric Araujo <merwok@netwok.org>
Thu, 2 Jun 2011 12:54:44 +0000 (14:54 +0200)
committerÉric Araujo <merwok@netwok.org>
Thu, 2 Jun 2011 12:54:44 +0000 (14:54 +0200)
Lib/packaging/command/check.py
Lib/packaging/tests/test_command_check.py

index 94c4a97c15cba4c3c377f493a0f602f32f3cd301..6715db90b32fb3e5ba4de0a2563bfad346484cf7 100644 (file)
@@ -32,7 +32,7 @@ class check(Command):
         # 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."""
index 0bdd6163d0232837b6d92c6469157b8e102ffb01..271e457961c4a350ceb75e4ed2033f2cb8a7ce62 100644 (file)
@@ -124,6 +124,17 @@ class CheckTestCase(support.LoggingCatcher,
         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)