From c1457d6d47a7a255c4447b02aef7ecebb617f4d1 Mon Sep 17 00:00:00 2001 From: Jamie Lennox Date: Fri, 23 Aug 2019 14:14:38 +1000 Subject: [PATCH] Keep blank values query string values on request history We've already added empty query string matching to the matcher logic, we should also use this when looking at request history. Related: #101 --- requests_mock/request.py | 2 +- tests/test_request.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/requests_mock/request.py b/requests_mock/request.py index 8a192cf..05cbc3d 100644 --- a/requests_mock/request.py +++ b/requests_mock/request.py @@ -110,7 +110,7 @@ def query(self): @property def qs(self): if self._qs is None: - self._qs = urlparse.parse_qs(self.query) + self._qs = urlparse.parse_qs(self.query, keep_blank_values=True) return self._qs diff --git a/tests/test_request.py b/tests/test_request.py index c99d699..5477852 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -130,3 +130,7 @@ def test_hostname_default_port_https(self): def test_to_string(self): req = self.do_request(url='https://host.example.com/path') self.assertEqual('GET https://host.example.com/path', str(req)) + + def test_empty_query_string(self): + req = self.do_request(url='https://host.example.com/path?key') + self.assertEqual([''], req.qs['key'])