Merge "Make expected notifications output easier to read in tests"

This commit is contained in:
Jenkins
2017-10-12 20:32:21 +00:00
committed by Gerrit Code Review

View File

@@ -216,12 +216,13 @@ class NotificationSampleTestBase(test.TestCase,
def _wait_for_notifications(self, event_type, expected_count, timeout=1.0): def _wait_for_notifications(self, event_type, expected_count, timeout=1.0):
notifications = fake_notifier.wait_for_versioned_notifications( notifications = fake_notifier.wait_for_versioned_notifications(
event_type, n_events=expected_count, timeout=timeout) event_type, n_events=expected_count, timeout=timeout)
msg = ''.join('\n%s' % notif for notif in notifications)
self.assertEqual(expected_count, len(notifications), self.assertEqual(expected_count, len(notifications),
'Unexpected number of %s notifications ' 'Unexpected number of %s notifications '
'within the given timeout. ' 'within the given timeout. '
'Expected %d, got %d: %s' % 'Expected %d, got %d: %s' %
(event_type, expected_count, len(notifications), (event_type, expected_count, len(notifications), msg))
notifications))
return notifications return notifications
def _attach_volume_to_server(self, server, volume_id): def _attach_volume_to_server(self, server, volume_id):