Skip to content

Commit

Permalink
fix(forum): make test_queries reproductible
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Oct 4, 2023
1 parent 866cc91 commit cb13144
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lacommunaute/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.contrib.contenttypes.models import ContentType
from django.template.defaultfilters import truncatechars_html
from django.test import RequestFactory, TestCase
from django.urls import reverse
Expand Down Expand Up @@ -227,9 +228,11 @@ def test_cannot_submit_post(self, *args):
self.assertNotContains(response, f'id="collapsePost{self.topic.pk}')

def test_queries(self):
ContentType.objects.clear_cache()

TopicFactory.create_batch(20, with_post=True)
self.client.force_login(self.user)
with self.assertNumQueries(22):
with self.assertNumQueries(23):
self.client.get(self.url)

def test_certified_post_display(self):
Expand Down

0 comments on commit cb13144

Please sign in to comment.