diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py index 2402f3d031b..5ec1a3f1845 100644 --- a/tests/generic_relations/tests.py +++ b/tests/generic_relations/tests.py @@ -320,6 +320,30 @@ class GenericRelationsTests(TestCase): self.assertEqual(1, bacon.tags.count()) self.assertEqual(1, qs.count()) + def test_clear(self): + self.assertSequenceEqual( + TaggedItem.objects.order_by('tag'), + [self.fatty, self.hairy, self.salty, self.yellow], + ) + self.bacon.tags.clear() + self.assertSequenceEqual(self.bacon.tags.all(), []) + self.assertSequenceEqual( + TaggedItem.objects.order_by('tag'), + [self.hairy, self.yellow], + ) + + def test_remove(self): + self.assertSequenceEqual( + TaggedItem.objects.order_by('tag'), + [self.fatty, self.hairy, self.salty, self.yellow], + ) + self.bacon.tags.remove(self.fatty) + self.assertSequenceEqual(self.bacon.tags.all(), [self.salty]) + self.assertSequenceEqual( + TaggedItem.objects.order_by('tag'), + [self.hairy, self.salty, self.yellow], + ) + def test_generic_relation_related_name_default(self): # GenericRelation isn't usable from the reverse side by default. msg = (