From 6b1c6abb4d08522b41c129b4b426eeb16e03bd9a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 16 Jun 2015 23:33:03 +0200 Subject: tests/test_paths.py: Add an 'always' warning filter, so it is reliable Previously, the warning was not always issued, causing the test to fail in some cases. Also change the assertions to use the assert* methods of unittest, and check that md5 and hash are mentioned in the deprecation message. Thanks: Adam Conrad Gbp-Dch: ignore --- tests/test_paths.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test_paths.py b/tests/test_paths.py index 222848f7..d647e6e2 100644 --- a/tests/test_paths.py +++ b/tests/test_paths.py @@ -42,13 +42,17 @@ class TestPath(unittest.TestCase): AcquireFile """ with warnings.catch_warnings(record=True) as caught_warnings: + warnings.simplefilter("always") apt_pkg.AcquireFile( apt_pkg.Acquire(), "http://example.com", destfile=self.file_bytes, md5="abcdef") - assert len(caught_warnings) == 1 - assert issubclass(caught_warnings[0].category, DeprecationWarning) + self.assertEqual(len(caught_warnings), 1) + self.assertTrue(issubclass(caught_warnings[0].category, + DeprecationWarning)) + self.assertIn("md5", str(caught_warnings[0].message)) + self.assertIn("hash", str(caught_warnings[0].message)) apt_pkg.AcquireFile( apt_pkg.Acquire(), "http://example.com", -- cgit v1.2.3