From 9bd4fc31e7bab1d21957dbe1141eff1559bc3b63 Mon Sep 17 00:00:00 2001 From: Matti Eiden Date: Tue, 27 Jan 2026 12:27:30 +0200 Subject: [PATCH] test: fix flaky test Force the second address to have some other municipality than Helsinki to avoid faker generating Helsinki for it with a 1 / 308 chance. --- address/tests/test_api_views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/address/tests/test_api_views.py b/address/tests/test_api_views.py index ea52de8..331e751 100644 --- a/address/tests/test_api_views.py +++ b/address/tests/test_api_views.py @@ -87,8 +87,9 @@ def test_filter_addresses_by_street_letter(api_client: APIClient): @mark.django_db def test_filter_addresses_by_municipality(api_client: APIClient): municipality = MunicipalityFactory(name="Helsinki") + other_municipality = MunicipalityFactory(name="Turpere") match = AddressFactory(municipality=municipality) - AddressFactory() + AddressFactory(municipality=other_municipality) serializer = AddressSerializer() response = api_client.get( reverse("address:address-list"), {"municipality": municipality.name}