Skip to content

Commit

Permalink
more efficient fix for cache issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Nov 19, 2024
1 parent 3bdf7d3 commit c4db8fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lemarche/www/siaes/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import mock

from django.contrib.gis.geos import Point
from django.contrib.sites.models import Site
from django.test import TestCase
from django.urls import reverse

Expand Down Expand Up @@ -59,8 +60,9 @@ def setUpTestData(cls):
def test_search_num_queries(self):
url = reverse("siae:search_results")

# fix cache issue in parallel testing context, "SELECT 'django_site'" query appears additionally otherwise
self.client.get(url)
# fix cache issue in parallel testing context because only first call fetches database
# See https://docs.djangoproject.com/en/5.1/ref/contrib/sites/#caching-the-current-site-object
Site.objects.get_current()

with self.assertNumQueries(12):
response = self.client.get(url)
Expand Down

0 comments on commit c4db8fc

Please sign in to comment.