From 2374b499b34039981016195bf2e9f06a271e0361 Mon Sep 17 00:00:00 2001 From: James Murty Date: Fri, 19 May 2017 15:04:30 +1000 Subject: [PATCH] Make unit tests less fragile --- icekit_events/tests/tests.py | 48 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/icekit_events/tests/tests.py b/icekit_events/tests/tests.py index 5141b89..7ff7e4d 100644 --- a/icekit_events/tests/tests.py +++ b/icekit_events/tests/tests.py @@ -763,37 +763,31 @@ def setUp(self): self.child_event_3 = G(SimpleEvent, part_of=self.parent_event) def test_upcoming(self): - self.assertEqual(list(SimpleEvent.objects.with_upcoming_occurrences()), [ - self.child_event_2, - ]) + self.assertEqual( + set(SimpleEvent.objects.with_upcoming_occurrences()), + set([self.child_event_2])) - self.assertEqual(list(SimpleEvent.objects.with_no_occurrences()), [ - self.parent_event, - self.child_event_3, - ]) + self.assertEqual( + set(SimpleEvent.objects.with_no_occurrences()), + set([self.parent_event, self.child_event_3])) - self.assertEqual(list(SimpleEvent.objects.with_upcoming_or_no_occurrences()), [ - self.parent_event, - self.child_event_2, - self.child_event_3, - ]) + self.assertEqual( + set(SimpleEvent.objects.with_upcoming_or_no_occurrences()), + set([self.parent_event, self.child_event_2, self.child_event_3])) def test_contained(self): - self.assertEqual(list(self.parent_event.get_children()), [ - self.child_event_1, - self.child_event_2, - self.child_event_3, - ]) - self.assertEqual(list(self.parent_event.get_children().with_upcoming_occurrences()), [ - self.child_event_2, - ]) - self.assertEqual(list(self.parent_event.get_children().with_no_occurrences()), [ - self.child_event_3, - ]) - self.assertEqual(list(self.parent_event.get_children().with_upcoming_or_no_occurrences()), [ - self.child_event_2, - self.child_event_3, - ]) + self.assertEqual( + set(self.parent_event.get_children()), + set([self.child_event_1, self.child_event_2, self.child_event_3])) + self.assertEqual( + set(self.parent_event.get_children().with_upcoming_occurrences()), + set([self.child_event_2])) + self.assertEqual( + set(self.parent_event.get_children().with_no_occurrences()), + set([self.child_event_3])) + self.assertEqual( + set(self.parent_event.get_children().with_upcoming_or_no_occurrences()), + set([self.child_event_2, self.child_event_3])) class TestEventRepeatOccurrencesRespectLocalTimeDefinition(TestCase):