summaryrefslogtreecommitdiff
path: root/tests/template_tests/syntax_tests/test_querystring.py
diff options
context:
space:
mode:
authorNatalia <124304+nessita@users.noreply.github.com>2025-03-20 11:32:54 -0300
committernessita <124304+nessita@users.noreply.github.com>2025-03-24 11:53:42 -0300
commit0b4f2d8d397dacb555b327435d1c815da59feda5 (patch)
treed7132afaeee330003bd2b04363e34470e5272d60 /tests/template_tests/syntax_tests/test_querystring.py
parentb1c1fd33ed7a1192050b25bd0a256a97326d7692 (diff)
Fixed #36268 -- Added leading `?` in every querystring template tag result.
Thanks Sarah Boyce for the report.
Diffstat (limited to 'tests/template_tests/syntax_tests/test_querystring.py')
-rw-r--r--tests/template_tests/syntax_tests/test_querystring.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/template_tests/syntax_tests/test_querystring.py b/tests/template_tests/syntax_tests/test_querystring.py
index 4070df34b2..7b19bb11ad 100644
--- a/tests/template_tests/syntax_tests/test_querystring.py
+++ b/tests/template_tests/syntax_tests/test_querystring.py
@@ -16,17 +16,15 @@ class QueryStringTagTests(SimpleTestCase):
@setup({"querystring_empty_get_params": "{% querystring %}"})
def test_querystring_empty_get_params(self):
context = RequestContext(self.request_factory.get("/"))
- self.assertRenderEqual("querystring_empty_get_params", context, expected="")
+ self.assertRenderEqual("querystring_empty_get_params", context, expected="?")
@setup({"querystring_remove_all_params": "{% querystring a=None %}"})
def test_querystring_remove_all_params(self):
non_empty_context = RequestContext(self.request_factory.get("/?a=b"))
empty_context = RequestContext(self.request_factory.get("/"))
- for context, expected in [(non_empty_context, "?"), (empty_context, "")]:
- with self.subTest(expected=expected):
- self.assertRenderEqual(
- "querystring_remove_all_params", context, expected
- )
+ for context in [non_empty_context, empty_context]:
+ with self.subTest(context=context):
+ self.assertRenderEqual("querystring_remove_all_params", context, "?")
@setup({"querystring_non_empty_get_params": "{% querystring %}"})
def test_querystring_non_empty_get_params(self):
@@ -46,10 +44,20 @@ class QueryStringTagTests(SimpleTestCase):
def test_querystring_empty_params(self):
cases = [None, {}, QueryDict()]
request = self.request_factory.get("/")
+ qs = "?a=b"
+ request_with_qs = self.request_factory.get(f"/{qs}")
for param in cases:
+ # Empty `query_dict` and nothing on `request.GET`.
with self.subTest(param=param):
context = RequestContext(request, {"qd": param})
- self.assertRenderEqual("querystring_empty_params", context, expected="")
+ self.assertRenderEqual(
+ "querystring_empty_params", context, expected="?"
+ )
+ # Empty `query_dict` and a query string in `request.GET`.
+ with self.subTest(param=param, qs=qs):
+ context = RequestContext(request_with_qs, {"qd": param})
+ expected = "?" if param is not None else qs
+ self.assertRenderEqual("querystring_empty_params", context, expected)
@setup({"querystring_replace": "{% querystring a=1 %}"})
def test_querystring_replace(self):