Skip to content
Myr

Merge pull request #4915 from sethmlarson/patch-1

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

Normalize percent-encoded bytes before comparison

authored by Ian Stapleton Cordasco · committed by GitHub · parents f37daf2, 2820839 · Browse files · 4 files+13 added−4 removed
This commit

State

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

Diff stats

4 files+13 added−4 removed

  • tests:+10 added−1 removed
  • other:+3 added−3 removed

4 files+13 added−4 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
modified:.travis.yml+1 added-1 removed
modified:Makefile+1 added-1 removed
1.PHONY: docs2init:3 pip install pipenv --upgrade4 pipenv install --dev --skip-lock4 pipenv install --dev5test:6 # This runs all of the tests, on both Python 2 and Python 3.7 detox8ci:
20 unmodified lines
modified:Pipfile+1 added-1 removed
2 unmodified lines
3verify_ssl = true4name = "pypi"56[dev-packages]7pytest = ">=2.8.0"7pytest = ">=2.8.0,<4.1"8codecov = "*"9pytest-httpbin = ">=0.0.7"10pytest-mock = "*"11pytest-cov = "*"
13 unmodified lines