Skip to content

Commit

Permalink
Merge pull request #100 from Colin-b/develop
Browse files Browse the repository at this point in the history
Release 0.23.0
  • Loading branch information
Colin-b authored Aug 1, 2023
2 parents 7127844 + 62d9179 commit cb7dda5
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11']
pytest-major-version: ['6', '7']

steps:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
repos:
- repo: https:/psf/black
rev: 22.12.0
rev: 23.7.0
hooks:
- id: black
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.23.0] - 2023-08-02
### Removed
- Python `3.7` and `3.8` are no longer supported.

### Fixed
- `httpx_mock.add_response` is now returning a new `httpx.Response` instance upon each matching request. Preventing unnecessary cascading streams.

## [0.22.0] - 2023-04-12
### Changed
- Requires [`httpx`](https://www.python-httpx.org)==0.24.\*
Expand All @@ -29,7 +36,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Requires [`httpx`](https://www.python-httpx.org)==0.23.\*

### Removed
- Python 3.6 is no longer supported.
- Python `3.6` is no longer supported.

## [0.20.0] - 2022-02-05
### Added
Expand Down Expand Up @@ -241,7 +248,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- First release, should be considered as unstable for now as design might change.

[Unreleased]: https:/Colin-b/pytest_httpx/compare/v0.22.0...HEAD
[Unreleased]: https:/Colin-b/pytest_httpx/compare/v0.23.0...HEAD
[0.23.0]: https:/Colin-b/pytest_httpx/compare/v0.22.0...v0.23.0
[0.22.0]: https:/Colin-b/pytest_httpx/compare/v0.21.3...v0.22.0
[0.21.3]: https:/Colin-b/pytest_httpx/compare/v0.21.2...v0.21.3
[0.21.2]: https:/Colin-b/pytest_httpx/compare/v0.21.1...v0.21.2
Expand Down
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include CHANGELOG.md
recursive-include tests *.py
3 changes: 2 additions & 1 deletion pytest_httpx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from collections.abc import Generator
from typing import List

import httpx
Expand Down Expand Up @@ -34,7 +35,7 @@ def httpx_mock(
monkeypatch: MonkeyPatch,
assert_all_responses_were_requested: bool,
non_mocked_hosts: List[str],
) -> HTTPXMock:
) -> Generator[HTTPXMock, None, None]:
# Ensure redirections to www hosts are handled transparently.
missing_www = [
f"www.{host}" for host in non_mocked_hosts if not host.startswith("www.")
Expand Down
25 changes: 14 additions & 11 deletions pytest_httpx/_httpx_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,20 @@ def add_response(
:param match_headers: HTTP headers identifying the request(s) to match. Must be a dictionary.
:param match_content: Full HTTP body identifying the request(s) to match. Must be bytes.
"""
response = httpx.Response(
status_code=status_code,
extensions={"http_version": http_version.encode("ascii")},
headers=headers,
json=json,
content=content,
text=text,
html=html,
stream=stream,
)
self.add_callback(lambda request: response, **matchers)

def response_callback(request: httpx.Request) -> httpx.Response:
return httpx.Response(
status_code=status_code,
extensions={"http_version": http_version.encode("ascii")},
headers=headers,
json=json,
content=content,
text=text,
html=html,
stream=stream,
)

self.add_callback(response_callback, **matchers)

This comment has been minimized.

Copy link
@tomchristie

tomchristie Aug 3, 2023

👍 Nicely done, yep.


def add_callback(
self,
Expand Down
2 changes: 1 addition & 1 deletion pytest_httpx/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# Major should be incremented in case there is a breaking change. (eg: 2.5.8 -> 3.0.0)
# Minor should be incremented in case there is an enhancement. (eg: 2.5.8 -> 2.6.0)
# Patch should be incremented in case there is a bug fix. (eg: 2.5.8 -> 2.5.9)
__version__ = "0.22.0"
__version__ = "0.23.0"
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
"Typing :: Typed",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -45,12 +43,12 @@
extras_require={
"testing": [
# Used to run async test functions
"pytest-asyncio==0.20.*",
"pytest-asyncio==0.21.*",
# Used to check coverage
"pytest-cov==4.*",
]
},
python_requires=">=3.7",
python_requires=">=3.9",
project_urls={
"GitHub": "https:/Colin-b/pytest_httpx",
"Changelog": "https:/Colin-b/pytest_httpx/blob/master/CHANGELOG.md",
Expand Down

0 comments on commit cb7dda5

Please sign in to comment.