From fd2aaef4d13ca8a78efb17c0322fffc15ff7eced Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Wed, 1 Nov 2023 23:02:24 +0000 Subject: [PATCH] refactor(test): less dependence on database contents --- tests/pytest/core/test_models.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/pytest/core/test_models.py b/tests/pytest/core/test_models.py index eb345920bc..6df589ce05 100644 --- a/tests/pytest/core/test_models.py +++ b/tests/pytest/core/test_models.py @@ -329,16 +329,18 @@ def test_TransitAgency_by_slug_nonmatching(): @pytest.mark.django_db def test_TransitAgency_all_active(model_TransitAgency): - assert TransitAgency.objects.count() == 1 + count = TransitAgency.objects.count() + assert count >= 1 inactive_agency = TransitAgency.by_id(model_TransitAgency.id) inactive_agency.pk = None inactive_agency.active = False inactive_agency.save() - assert TransitAgency.objects.count() == 2 + assert TransitAgency.objects.count() == count + 1 result = TransitAgency.all_active() - assert len(result) == 1 + assert len(result) > 0 assert model_TransitAgency in result + assert inactive_agency not in result