From e243dbcfb1ff37fe041ee4a105e619f3f184913a Mon Sep 17 00:00:00 2001 From: Rust Saiargaliev Date: Fri, 9 Aug 2024 16:40:59 +0200 Subject: [PATCH] Small test improvements --- tests/test_baker.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/test_baker.py b/tests/test_baker.py index e0c48744..46c26c44 100644 --- a/tests/test_baker.py +++ b/tests/test_baker.py @@ -1059,9 +1059,9 @@ def test_annotation_within_manager_get_queryset_are_run_on_make(self): @pytest.mark.django_db class TestCreateM2MWhenBulkCreate(TestCase): def test_create(self): - query_count = 12 - with self.assertNumQueries(query_count): - person = baker.make(models.Person) + person = baker.make(models.Person) + + with self.assertNumQueries(11): baker.make( models.Classroom, students=[person], _quantity=10, _bulk_create=True ) @@ -1072,14 +1072,16 @@ def test_make_should_create_objects_using_reverse_name(self): classroom = baker.make(models.Classroom) with self.assertNumQueries(21): - students = baker.make( + baker.make( models.Person, classroom_set=[classroom], _quantity=10, _bulk_create=True, ) - - assert students[0].classroom_set.count() == 1 + s1, s2 = models.Person.objects.all()[:2] + assert ( + list(s1.classroom_set.all()) == list(s2.classroom_set.all()) == [classroom] + ) class TestBakerSeeded: