Skip to content

Commit dcfd67a

Browse files
committed
test: close coverage gaps in _parse_query and _split_query_tail fallbacks
Adds cases for the fallback paths introduced in the lenient-query fixes: literal ? in path portion, {?...} expression in path portion, empty & segments in query string, and duplicate query keys.
1 parent 2bedd9d commit dcfd67a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/shared/test_uri_template.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,14 @@ def test_expand_rejects_invalid_value_types(value: object):
448448
# Standalone {&var} falls through to strict regex (expands with
449449
# & prefix, no ? for lenient matching to split on)
450450
("api{&page}", "api&page=2", {"page": "2"}),
451+
# Literal ? in path portion falls through to strict regex
452+
("api?x{?page}", "api?x?page=2", {"page": "2"}),
453+
# {?...} expression in path portion also falls through
454+
("api{?q}x{?page}", "api?q=1x?page=2", {"q": "1", "page": "2"}),
455+
# Empty & segments in query are skipped
456+
("search{?q}", "search?&q=hello&", {"q": "hello"}),
457+
# Duplicate query keys keep first value
458+
("search{?q}", "search?q=first&q=second", {"q": "first"}),
451459
# Level 3: query continuation with literal ? falls back to
452460
# strict regex (template-order, all-present required)
453461
("?a=1{&b}", "?a=1&b=2", {"b": "2"}),

0 commit comments

Comments
 (0)