Better error messages in tests

This commit is contained in:
Lars Immisch
2020-07-13 20:51:59 +02:00
parent 08bdce9ed9
commit b17b36be50
+6 -5
View File
@@ -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()