def test_parse_qs(): """urllib_utf8.parse_qs should mostly act like urlparse.parse_qs.""" strings = ['', 'foo=bar', u'foo=bar', 'foo=bar&baz=quux', 'foo=1&foo=2'] for query_string in strings: assert urllib_utf8.parse_qs(query_string) == urllib.parse.parse_qs(query_string) utf8_string = query_string.encode('utf-8') if isinstance(query_string, six.text_type) else query_string assert urllib_utf8.parse_qs(utf8_string) == urllib.parse.parse_qs(utf8_string)
def test_parse_qs(): """urllib_utf8.parse_qs should mostly act like urlparse.parse_qs.""" strings = ['', 'foo=bar', u'foo=bar', 'foo=bar&baz=quux', 'foo=1&foo=2'] for query_string in strings: assert urllib_utf8.parse_qs(query_string) == urlparse.parse_qs(query_string) utf8_string = query_string.encode('utf-8') if isinstance(query_string, unicode) else query_string assert urllib_utf8.parse_qs(query_string) == urlparse.parse_qs(utf8_string) assert urllib_utf8.parse_qs(query_string) == urlparse.parse_qs(utf8_string)
def _verify_extract_unicode_value(query_string, expected_value): """Verify the first 'foo=X' value matches expected_value.""" kwargs = urllib_utf8.parse_qs(query_string) assert kwargs['foo'][0] == expected_value