# HG changeset patch # User Thomas De Schampheleire # Date 2015-06-22 14:56:01 # Node ID ac5d236a995aed95fb28692b1b863cc746b86647 # Parent aacc82d4a96719e63d86fb9c69bd6f43517566dd tests: improve robustness of notifications tests The notifications tests make the assumption that there are no notifications at the start of the test, which is explicitly asserted. However, any other test, like the one introduced in commit 9a23b444a7fe (pullrequests: detect invalid reviewers and raise HTTPBadRequest), could add new notifications to the database, and thus fail these assertions. Just like the notifications tests already cleaned all notifications at the end of the test (tearDown), make sure to clean them at the start (setUp) too. diff --git a/kallithea/tests/models/test_notifications.py b/kallithea/tests/models/test_notifications.py --- a/kallithea/tests/models/test_notifications.py +++ b/kallithea/tests/models/test_notifications.py @@ -41,6 +41,9 @@ class TestNotifications(BaseTestCase): Session().commit() self.assertEqual(Notification.query().all(), []) + def setUp(self): + self._clean_notifications() + def tearDown(self): self._clean_notifications() @@ -156,7 +159,6 @@ class TestNotifications(BaseTestCase): self.assertNotEqual(u2notification, None) def test_notification_counter(self): - self._clean_notifications() self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all())