# HG changeset patch # User Thomas De Schampheleire # Date 1434977761 -7200 # 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 -r aacc82d4a967 -r ac5d236a995a kallithea/tests/models/test_notifications.py --- a/kallithea/tests/models/test_notifications.py Sat Jun 20 22:10:05 2015 +0200 +++ b/kallithea/tests/models/test_notifications.py Mon Jun 22 14:56:01 2015 +0200 @@ -41,6 +41,9 @@ Session().commit() self.assertEqual(Notification.query().all(), []) + def setUp(self): + self._clean_notifications() + def tearDown(self): self._clean_notifications() @@ -156,7 +159,6 @@ self.assertNotEqual(u2notification, None) def test_notification_counter(self): - self._clean_notifications() self.assertEqual([], Notification.query().all()) self.assertEqual([], UserNotification.query().all())