Skip to content
Myr

Normalize percent-encoded bytes before comparison

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Seth M. Larson · committed by GitHub · parent 5c1f72e · Browse files · 1 file+10 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+10 added−1 removed

  • tests:+10 added−1 removed

1 file+10 added−1 removed

modified:tests/test_requests.py+10 added-1 removed
7 unmodified lines
8import pickle9import collections10import contextlib11import warnings12import re1314import io15import requests16import pytest
2401 unmodified lines
2418 )2419 )2420 )2421 def test_preparing_url(self, url, expected):24222423 def normalize_percent_encode(x):2424 # Helper function that normalizes equivalent 2425 # percent-encoded bytes before comparisons2426 for c in re.findall(r'%[a-fA-F0-9]{2}', x):2427 x = x.replace(c, c.upper())2428 return x2429 2430 r = requests.Request('GET', url=url)2431 p = r.prepare()2423 assert p.url == expected2432 assert normalize_percent_encode(p.url) == expected24332434 @pytest.mark.parametrize(2435 'url',2436 (
91 unmodified lines