From b17b36be50079d2bb6721c60f6111bd02c927888 Mon Sep 17 00:00:00 2001 From: Lars Immisch Date: Mon, 13 Jul 2020 20:51:59 +0200 Subject: [PATCH] Better error messages in tests --- test.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test.py b/test.py index c3197e4..b8f987f 100755 --- a/test.py +++ b/test.py @@ -135,9 +135,9 @@ class PCMTest(unittest.TestCase): pass # Verify we got a DepreciationWarning - assert len(w) == 1 - assert issubclass(w[-1].category, DeprecationWarning) - + self.assertEqual(len(w), 1, "PCM(card='default') expected a warning" ) + self.assertTrue(issubclass(w[-1].category, DeprecationWarning), "PCM(card='default') expected a DeprecationWarning") + for m, a in PCMDeprecatedMethods: with warnings.catch_warnings(record=True) as w: # Cause all warnings to always be triggered. @@ -152,8 +152,9 @@ class PCMTest(unittest.TestCase): f(pcm, *a) # Verify we got a DepreciationWarning - assert len(w) == 1 - assert issubclass(w[-1].category, DeprecationWarning) + method = "%s%s" % (m, str(a)) + self.assertEqual(len(w), 1, method + " expected a warning") + self.assertTrue(issubclass(w[-1].category, DeprecationWarning), method + " expected a DeprecationWarning") if __name__ == '__main__': unittest.main()