Skip to content

Commit

Permalink
LITE-30282: Support pytest-httpx >=0.27.0, drop Python 3.8 compatibil…
Browse files Browse the repository at this point in the history
…ity, add Python 3.12 to test matrix
  • Loading branch information
r-s11v committed Jun 4, 2024
1 parent f8423e3 commit d686bc5
Show file tree
Hide file tree
Showing 8 changed files with 437 additions and 515 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ play with the CloudBlue Connect API using a python REPL like [jupyter](https://j

## Install

`Connect Python OpenAPI Client` requires python 3.8 or later.
`Connect Python OpenAPI Client` requires python 3.9 or later.


`Connect Python OpenAPI Client` can be installed from [pypi.org](https://pypi.org/project/connect-openapi-client/) using pip:
Expand Down
21 changes: 11 additions & 10 deletions connect/client/testing/fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import responses
from pytest import MonkeyPatch
from pytest_httpx import HTTPXMock
from pytest_httpx._httpx_mock import _PytestAsyncTransport
from responses import matchers

from connect.client.fluent import _ConnectClientBase
Expand Down Expand Up @@ -176,20 +175,22 @@ def __init__(self, base_url, exclude=None):

def start(self):
patterns = self.exclude if isinstance(self.exclude, (list, tuple, set)) else [self.exclude]
real_async_transport = httpx.AsyncClient._transport_for_url
real_handle_async_request = httpx.AsyncHTTPTransport.handle_async_request

def transport_for_url(self, url):
async def mocked_handle_async_request(
transport: httpx.AsyncHTTPTransport, request: httpx.Request
) -> httpx.Response:
for pattern in patterns:
if (isinstance(pattern, re.Pattern) and pattern.match(str(url))) or (
isinstance(pattern, str) and str(url).startswith(pattern)
if (isinstance(pattern, re.Pattern) and pattern.match(str(request.url))) or (
isinstance(pattern, str) and str(request.url).startswith(pattern)
):
return real_async_transport(self, url)
return _PytestAsyncTransport(_async_mocker)
return await real_handle_async_request(transport, request)
return await _async_mocker._handle_async_request(transport, request)

_monkeypatch.setattr(
httpx.AsyncClient,
'_transport_for_url',
transport_for_url,
httpx.AsyncHTTPTransport,
"handle_async_request",
mocked_handle_async_request,
)

def reset(self, success=True):
Expand Down
799 changes: 361 additions & 438 deletions poetry.lock

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "connect-openapi-client"
version = "25.16"
version = "29.4"
description = "Connect Python OpenAPI Client"
authors = ["CloudBlue"]
license = "Apache-2.0"
Expand All @@ -17,9 +17,10 @@ classifiers = [
"Environment :: Console",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Utilities",
"Topic :: Software Development :: Libraries",
]
Expand All @@ -34,32 +35,32 @@ keywords = [
]

[tool.poetry.dependencies]
python = ">=3.8,<4"
python = ">=3.9,<4"
connect-markdown-renderer = "^3"
PyYAML = ">=5.3.1"
requests = ">=2.23"
inflect = ">=4.1"
httpx = ">=0.23"
asgiref = "^3.3.4"
responses = ">=0.14.0,<1"
pytest-httpx = ">=0.20,<0.27"
pytest-httpx = ">=0.27"
importlib-metadata = "^6.6"
urllib3 = "<2"

[tool.poetry.group.test.dependencies]
black = "23.*"
pytest = ">=6.1.2,<8"
pytest-cov = ">=2.10.1,<5"
pytest-mock = "^3.10"
coverage = {extras = ["toml"], version = ">=5.3,<7"}
flake8 = ">=3.8,<6"
flake8 = ">=6"
flake8-black = "0.*"
flake8-bugbear = ">=20,<23"
flake8-cognitive-complexity = "^0.1"
flake8-commas = "~2.1"
flake8-commas = "~4"
flake8-future-import = "~0.4"
flake8-import-order = ">=0.18.2"
flake8-isort = "^6.0"
flake8-broken-line = ">=0.3,<0.7"
flake8-broken-line = ">=1.0"
flake8-pyproject = "^1.2.3"
isort = "^5.10"
pytest-asyncio = "^0.15.1"
Expand Down
109 changes: 54 additions & 55 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
annotated-types==0.5.0 ; python_version >= "3.8" and python_version < "4"
anyio==4.0.0 ; python_version >= "3.8" and python_version < "4"
asgiref==3.7.2 ; python_version >= "3.8" and python_version < "4"
certifi==2023.7.22 ; python_version >= "3.8" and python_version < "4"
charset-normalizer==3.2.0 ; python_version >= "3.8" and python_version < "4"
click==8.1.7 ; python_version >= "3.8" and python_version < "4"
colorama==0.4.6 ; python_version >= "3.8" and python_version < "4"
commonmark==0.9.1 ; python_version >= "3.8" and python_version < "4"
connect-markdown-renderer==3.0.0 ; python_version >= "3.8" and python_version < "4"
exceptiongroup==1.1.3 ; python_version >= "3.8" and python_version < "3.11"
ghp-import==2.1.0 ; python_version >= "3.8" and python_version < "4"
griffe==0.36.2 ; python_version >= "3.8" and python_version < "4"
h11==0.14.0 ; python_version >= "3.8" and python_version < "4"
httpcore==0.17.3 ; python_version >= "3.8" and python_version < "4"
httpx==0.24.1 ; python_version >= "3.8" and python_version < "4"
idna==3.4 ; python_version >= "3.8" and python_version < "4"
importlib-metadata==6.8.0 ; python_version >= "3.8" and python_version < "4"
inflect==7.0.0 ; python_version >= "3.8" and python_version < "4"
iniconfig==2.0.0 ; python_version >= "3.8" and python_version < "4"
jinja2==3.1.2 ; python_version >= "3.8" and python_version < "4"
markdown-it-py==2.2.0 ; python_version >= "3.8" and python_version < "4"
markdown==3.4.4 ; python_version >= "3.8" and python_version < "4"
markupsafe==2.1.3 ; python_version >= "3.8" and python_version < "4"
mdurl==0.1.2 ; python_version >= "3.8" and python_version < "4"
mergedeep==1.3.4 ; python_version >= "3.8" and python_version < "4"
mkdocs-autorefs==0.5.0 ; python_version >= "3.8" and python_version < "4"
mkdocs-material-extensions==1.1.1 ; python_version >= "3.8" and python_version < "4"
mkdocs-material==8.5.11 ; python_version >= "3.8" and python_version < "4"
mkdocs==1.5.2 ; python_version >= "3.8" and python_version < "4"
mkdocstrings-python==0.8.3 ; python_version >= "3.8" and python_version < "4"
mkdocstrings==0.20.0 ; python_version >= "3.8" and python_version < "4"
packaging==23.1 ; python_version >= "3.8" and python_version < "4"
pathspec==0.11.2 ; python_version >= "3.8" and python_version < "4"
platformdirs==3.10.0 ; python_version >= "3.8" and python_version < "4"
pluggy==1.3.0 ; python_version >= "3.8" and python_version < "4"
pydantic-core==2.6.3 ; python_version >= "3.8" and python_version < "4"
pydantic==2.3.0 ; python_version >= "3.8" and python_version < "4"
pygments==2.16.1 ; python_version >= "3.8" and python_version < "4"
pymdown-extensions==10.3 ; python_version >= "3.8" and python_version < "4"
pytest-httpx==0.22.0 ; python_version >= "3.8" and python_version < "4"
pytest==7.4.2 ; python_version >= "3.8" and python_version < "4"
python-dateutil==2.8.2 ; python_version >= "3.8" and python_version < "4"
pyyaml-env-tag==0.1 ; python_version >= "3.8" and python_version < "4"
pyyaml==6.0.1 ; python_version >= "3.8" and python_version < "4"
requests==2.31.0 ; python_version >= "3.8" and python_version < "4"
responses==0.23.3 ; python_version >= "3.8" and python_version < "4"
rich==12.6.0 ; python_version >= "3.8" and python_version < "4"
six==1.16.0 ; python_version >= "3.8" and python_version < "4"
sniffio==1.3.0 ; python_version >= "3.8" and python_version < "4"
tomli==2.0.1 ; python_version >= "3.8" and python_version < "3.11"
types-pyyaml==6.0.12.11 ; python_version >= "3.8" and python_version < "4"
typing-extensions==4.8.0 ; python_version >= "3.8" and python_version < "4"
urllib3==1.26.16 ; python_version >= "3.8" and python_version < "4"
watchdog==3.0.0 ; python_version >= "3.8" and python_version < "4"
zipp==3.16.2 ; python_version >= "3.8" and python_version < "4"
anyio==4.4.0 ; python_version >= "3.9" and python_version < "4"
asgiref==3.8.1 ; python_version >= "3.9" and python_version < "4"
certifi==2024.6.2 ; python_version >= "3.9" and python_version < "4"
charset-normalizer==3.3.2 ; python_version >= "3.9" and python_version < "4"
click==8.1.7 ; python_version >= "3.9" and python_version < "4"
colorama==0.4.6 ; python_version >= "3.9" and python_version < "4"
commonmark==0.9.1 ; python_version >= "3.9" and python_version < "4"
connect-markdown-renderer==3.0.0 ; python_version >= "3.9" and python_version < "4"
exceptiongroup==1.2.1 ; python_version >= "3.9" and python_version < "3.11"
ghp-import==2.1.0 ; python_version >= "3.9" and python_version < "4"
griffe==0.45.2 ; python_version >= "3.9" and python_version < "4"
h11==0.14.0 ; python_version >= "3.9" and python_version < "4"
httpcore==1.0.5 ; python_version >= "3.9" and python_version < "4"
httpx==0.27.0 ; python_version >= "3.9" and python_version < "4"
idna==3.7 ; python_version >= "3.9" and python_version < "4"
importlib-metadata==6.11.0 ; python_version >= "3.9" and python_version < "4"
inflect==7.2.1 ; python_version >= "3.9" and python_version < "4"
iniconfig==2.0.0 ; python_version >= "3.9" and python_version < "4"
jinja2==3.1.4 ; python_version >= "3.9" and python_version < "4"
markdown-it-py==2.2.0 ; python_version >= "3.9" and python_version < "4"
markdown==3.6 ; python_version >= "3.9" and python_version < "4"
markupsafe==2.1.5 ; python_version >= "3.9" and python_version < "4"
mdurl==0.1.2 ; python_version >= "3.9" and python_version < "4"
mergedeep==1.3.4 ; python_version >= "3.9" and python_version < "4"
mkdocs-autorefs==1.0.1 ; python_version >= "3.9" and python_version < "4"
mkdocs-get-deps==0.2.0 ; python_version >= "3.9" and python_version < "4"
mkdocs-material-extensions==1.3.1 ; python_version >= "3.9" and python_version < "4"
mkdocs-material==8.5.11 ; python_version >= "3.9" and python_version < "4"
mkdocs==1.6.0 ; python_version >= "3.9" and python_version < "4"
mkdocstrings-python==0.8.3 ; python_version >= "3.9" and python_version < "4"
mkdocstrings==0.20.0 ; python_version >= "3.9" and python_version < "4"
more-itertools==10.2.0 ; python_version >= "3.9" and python_version < "4"
packaging==24.0 ; python_version >= "3.9" and python_version < "4"
pathspec==0.12.1 ; python_version >= "3.9" and python_version < "4"
platformdirs==4.2.2 ; python_version >= "3.9" and python_version < "4"
pluggy==1.5.0 ; python_version >= "3.9" and python_version < "4"
pygments==2.18.0 ; python_version >= "3.9" and python_version < "4"
pymdown-extensions==10.8.1 ; python_version >= "3.9" and python_version < "4"
pytest-httpx==0.30.0 ; python_version >= "3.9" and python_version < "4"
pytest==7.4.4 ; python_version >= "3.9" and python_version < "4"
python-dateutil==2.9.0.post0 ; python_version >= "3.9" and python_version < "4"
pyyaml-env-tag==0.1 ; python_version >= "3.9" and python_version < "4"
pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "4"
requests==2.32.3 ; python_version >= "3.9" and python_version < "4"
responses==0.25.0 ; python_version >= "3.9" and python_version < "4"
rich==12.6.0 ; python_version >= "3.9" and python_version < "4"
six==1.16.0 ; python_version >= "3.9" and python_version < "4"
sniffio==1.3.1 ; python_version >= "3.9" and python_version < "4"
tomli==2.0.1 ; python_version >= "3.9" and python_version < "3.11"
typeguard==4.3.0 ; python_version >= "3.9" and python_version < "4"
typing-extensions==4.12.1 ; python_version >= "3.9" and python_version < "4"
urllib3==1.26.18 ; python_version >= "3.9" and python_version < "4"
watchdog==4.0.1 ; python_version >= "3.9" and python_version < "4"
zipp==3.19.1 ; python_version >= "3.9" and python_version < "4"
1 change: 0 additions & 1 deletion tests/async_client/test_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ async def test_execute_delete(httpx_mock):
httpx_mock.add_response(
method='DELETE',
url='https://localhost/resources',
text='error text',
status_code=204,
)

Expand Down
1 change: 0 additions & 1 deletion tests/client/test_fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,6 @@ def test_execute_delete(mocked_responses):
mocked_responses.add(
responses.DELETE,
'https://localhost/resources',
body='error text',
status=204,
)

Expand Down

0 comments on commit d686bc5

Please sign in to comment.