Skip to content

Commit

Permalink
chore: allow urllib3>=1.25.10 (#659)
Browse files Browse the repository at this point in the history
Allow use of urllib3>=1.25.10. By default it will use urllib3>=2 as
that is the latest version. But this will allow people to pin
urllib3<2 and still use the latest version of requests and responses.

Closes: #657
  • Loading branch information
JohnVillalovos committed Jul 31, 2023
1 parent 78854ab commit c226971
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
requests-version: ['"requests>=2.0,<3.0"']
urllib3-version: ['"urllib3<2"', '"urllib3>=2,<3.0"']


steps:
- uses: actions/checkout@v3
Expand All @@ -46,7 +48,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ${{ matrix.requests-version }}
pip install ${{ matrix.requests-version }} ${{ matrix.urllib3-version }}
make install-deps
- name: Run Pytest
Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.23.3
------

* Allow urllib3>=1.25.10


0.23.2
------

Expand Down
14 changes: 11 additions & 3 deletions responses/tests/test_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import pytest
import requests
import urllib3
from requests.exceptions import ChunkedEncodingError
from requests.exceptions import ConnectionError
from requests.exceptions import HTTPError
Expand Down Expand Up @@ -1534,10 +1535,17 @@ def run():
headers={"Content-Length": "2"},
auto_calculate_content_length=True,
)
with pytest.raises(ChunkedEncodingError) as excinfo:
requests.get(url)

assert "IncompleteRead(4 bytes read, -2 more expected)" in str(excinfo.value)
if urllib3.__version__ < "2":
resp = requests.get(url)
assert_response(resp, "test")
assert resp.headers["Content-Length"] == "2"
else:
with pytest.raises(ChunkedEncodingError) as excinfo:
requests.get(url)
assert "IncompleteRead(4 bytes read, -2 more expected)" in str(
excinfo.value
)

run()
assert_reset()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

install_requires = [
"requests>=2.30.0,<3.0",
"urllib3>=2.0.0,<3.0",
"urllib3>=1.25.10,<3.0",
"pyyaml",
"types-PyYAML",
"typing_extensions; python_version < '3.8'",
Expand Down

0 comments on commit c226971

Please sign in to comment.