diff options
Diffstat (limited to 'Lib/packaging/tests/test_command_check.py')
-rw-r--r-- | Lib/packaging/tests/test_command_check.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/Lib/packaging/tests/test_command_check.py b/Lib/packaging/tests/test_command_check.py index 8b32673..271e457 100644 --- a/Lib/packaging/tests/test_command_check.py +++ b/Lib/packaging/tests/test_command_check.py @@ -36,7 +36,6 @@ class CheckTestCase(support.LoggingCatcher, # now let's add the required fields # and run it again, to make sure we don't get # any warning anymore - self.loghandler.flush() metadata = {'home_page': 'xxx', 'author': 'xxx', 'author_email': 'xxx', 'name': 'xxx', 'version': '4.2', @@ -50,8 +49,10 @@ class CheckTestCase(support.LoggingCatcher, self.assertRaises(PackagingSetupError, self._run, {'name': 'xxx', 'version': 'xxx'}, **{'strict': 1}) - # and of course, no error when all metadata fields are present + # clear warnings from the previous calls self.loghandler.flush() + + # and of course, no error when all metadata fields are present cmd = self._run(metadata, strict=True) self.assertEqual([], self.get_logs(logging.WARNING)) @@ -70,7 +71,6 @@ class CheckTestCase(support.LoggingCatcher, 'name': 'xxx', 'version': '4.2', 'requires_python': '2.4', } - self.loghandler.flush() cmd = self._run(metadata) self.assertEqual([], self.get_logs(logging.WARNING)) @@ -85,9 +85,11 @@ class CheckTestCase(support.LoggingCatcher, self.assertRaises(PackagingSetupError, self._run, metadata, **{'strict': 1}) + # clear warnings from the previous calls + self.loghandler.flush() + # now with correct version format again metadata['version'] = '4.2' - self.loghandler.flush() cmd = self._run(metadata, strict=True) self.assertEqual([], self.get_logs(logging.WARNING)) @@ -100,7 +102,6 @@ class CheckTestCase(support.LoggingCatcher, cmd.check_restructuredtext() self.assertEqual(len(self.get_logs(logging.WARNING)), 1) - self.loghandler.flush() pkg_info, dist = self.create_dist(description='title\n=====\n\ntest') cmd = check(dist) cmd.check_restructuredtext() @@ -123,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) |