summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Roztocil <jakub@roztocil.co>2022-06-07 14:50:56 +0200
committerJakub Roztocil <jakub@roztocil.co>2022-06-07 14:50:56 +0200
commit9d2e2afedeb6e8c0dad0535a44a8acbc179f5bf7 (patch)
tree7df5befec0b50b80a4f8816ae7eca40a52c92794
parent418b12bbd6072585118c06c5c4e17996d7f0b085 (diff)
Add failing reproduction test casefix-initial-number-escaping
-rw-r--r--tests/test_regressions.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/test_regressions.py b/tests/test_regressions.py
index ddcf4acf..a225684c 100644
--- a/tests/test_regressions.py
+++ b/tests/test_regressions.py
@@ -1,9 +1,12 @@
"""Miscellaneous regression tests"""
import pytest
+from httpie.cli.argtypes import KeyValueArgType
+from httpie.cli.constants import SEPARATOR_HEADER, SEPARATOR_QUERY_PARAM, SEPARATOR_DATA_STRING
+from httpie.cli.requestitems import RequestItems
from httpie.compat import is_windows
-from .utils.matching import assert_output_matches, Expect
from .utils import HTTP_OK, MockEnvironment, http
+from .utils.matching import assert_output_matches, Expect
def test_Host_header_overwrite(httpbin):
@@ -47,3 +50,21 @@ def test_verbose_redirected_stdout_separator(httpbin):
Expect.RESPONSE_HEADERS,
Expect.BODY,
])
+
+
+@pytest.mark.parametrize(['separator', 'target'], [
+ (SEPARATOR_HEADER, 'headers'),
+ (SEPARATOR_QUERY_PARAM, 'params'),
+ (SEPARATOR_DATA_STRING, 'data'),
+])
+def test_initial_backslash_number(separator, target):
+ """
+ <https://github.com/httpie/httpie/issues/1408>
+ """
+ back_digit = r'\0'
+ raw_arg = back_digit + separator + back_digit
+ expected_parsed_data = {back_digit: back_digit}
+ parsed_arg = KeyValueArgType(separator)(raw_arg)
+ items = RequestItems.from_args([parsed_arg])
+ parsed_data = getattr(items, target)
+ assert parsed_data == expected_parsed_data