From a3e3dac6dc9034fccfa61fd581764cefccc66bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 6 Jul 2017 21:38:23 +0200 Subject: [PATCH] tests: improve test failure message When multiple Admin API calls are expected, but not all were made, show which were missing. --- qubesadmin/tests/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qubesadmin/tests/__init__.py b/qubesadmin/tests/__init__.py index df0dabe..d803a9d 100644 --- a/qubesadmin/tests/__init__.py +++ b/qubesadmin/tests/__init__.py @@ -158,8 +158,10 @@ class QubesTestCase(unittest.TestCase): set(self.app.expected_calls.keys()), set(self.app.actual_calls)) # and also check if calls expected multiple times were called - self.assertFalse(any(x for x in self.app.expected_calls.values() if - isinstance(x, list))) + self.assertFalse([(call, ret) + for call, ret in self.app.expected_calls.items() if + isinstance(ret, list) and ret], + 'Some calls not called expected number of times') def assertNotRaises(self, excClass, callableObj=None, *args, **kwargs): """Fail if an exception of class excClass is raised