Merge pull request #4915 from sethmlarson/patch-1

Normalize percent-encoded bytes before comparison
This commit is contained in:
Ian Stapleton Cordasco
2019-01-21 07:58:32 -06:00
committed by GitHub
4 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -38,5 +38,5 @@ jobs:
dist: xenial
sudo: true
- stage: coverage
python: 3.6
python: '3.6'
script: codecov
+1 -1
View File
@@ -1,7 +1,7 @@
.PHONY: docs
init:
pip install pipenv --upgrade
pipenv install --dev --skip-lock
pipenv install --dev
test:
# This runs all of the tests, on both Python 2 and Python 3.
detox
+1 -1
View File
@@ -4,7 +4,7 @@ verify_ssl = true
name = "pypi"
[dev-packages]
pytest = ">=2.8.0"
pytest = ">=2.8.0,<4.1"
codecov = "*"
pytest-httpbin = ">=0.0.7"
pytest-mock = "*"
+10 -1
View File
@@ -9,6 +9,7 @@ import pickle
import collections
import contextlib
import warnings
import re
import io
import requests
@@ -2418,9 +2419,17 @@ class TestPreparingURLs(object):
)
)
def test_preparing_url(self, url, expected):
def normalize_percent_encode(x):
# Helper function that normalizes equivalent
# percent-encoded bytes before comparisons
for c in re.findall(r'%[a-fA-F0-9]{2}', x):
x = x.replace(c, c.upper())
return x
r = requests.Request('GET', url=url)
p = r.prepare()
assert p.url == expected
assert normalize_percent_encode(p.url) == expected
@pytest.mark.parametrize(
'url',