Skip to content

Commit

Permalink
Small test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
amureki committed Aug 9, 2024
1 parent 6784e68 commit e243dbc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tests/test_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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:
Expand Down

0 comments on commit e243dbc

Please sign in to comment.