summaryrefslogtreecommitdiff
path: root/tests/test_utils
diff options
context:
space:
mode:
authorBaptiste Mispelon <baptiste.mispelon@torchbox.com>2026-01-12 14:51:32 +0100
committernessita <124304+nessita@users.noreply.github.com>2026-03-16 17:44:40 -0300
commit0ed8d4e7d1029e1283b04f70d51d2af96ad85d6a (patch)
treeed05472acc2f4cf13e4539d15f851ce139ff3e01 /tests/test_utils
parent4b2edb3418851c09dd839f1a2cba74051fe9d420 (diff)
Fixed #36859 -- Made assertContains and assertNotContains idempotent for streaming responses.
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/tests.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index ef1d02cf41..b9c8e2ac58 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -29,7 +29,7 @@ from django.forms import (
ValidationError,
formset_factory,
)
-from django.http import HttpResponse
+from django.http import HttpResponse, StreamingHttpResponse
from django.template import Context, Template
from django.template.loader import render_to_string
from django.test import (
@@ -1047,6 +1047,17 @@ class HTMLEqualTests(SimpleTestCase):
html=True,
)
+ def test_streaming_response_idempotent(self):
+ response = StreamingHttpResponse(["hello world"])
+ self.assertContains(response, "hello")
+ self.assertContains(response, "world")
+
+ def test_streaming_response_not_contains_idempotent(self):
+ response = StreamingHttpResponse(["hello world"])
+ self.assertNotContains(response, "bye")
+ self.assertNotContains(response, "bye")
+ self.assertContains(response, "world")
+
class InHTMLTests(SimpleTestCase):
def test_needle_msg(self):