Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-respx for openSUSE:Factory checked in at 2024-01-10 21:52:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-respx (Old) and /work/SRC/openSUSE:Factory/.python-respx.new.21961 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-respx" Wed Jan 10 21:52:18 2024 rev:6 rq:1137830 version:0.20.2 Changes: -------- --- /work/SRC/openSUSE:Factory/python-respx/python-respx.changes 2023-06-16 16:56:32.514308355 +0200 +++ /work/SRC/openSUSE:Factory/.python-respx.new.21961/python-respx.changes 2024-01-10 21:52:37.872913582 +0100 @@ -1,0 +2,13 @@ +Tue Jan 9 22:11:30 UTC 2024 - Dirk Müller <[email protected]> + +- update to 0.20.2: + * Better assertion output for `assert_all_called` + * Support for quoted path pattern matching + * Enable content\_\_contains pattern, thanks @rjprins + * Added initial `CONTRIBUTING.md`, thanks @morenoh149 + * Docs about retrieving mocked calls, thanks + * Docs about `Router.assert_all_called()`, thanks @BeyondEvil + for input +- drop use-real-ipv6-address.patch (upstream) + +------------------------------------------------------------------- Old: ---- respx-0.20.1.tar.gz use-real-ipv6-address.patch New: ---- respx-0.20.2.tar.gz BETA DEBUG BEGIN: Old: for input - drop use-real-ipv6-address.patch (upstream) BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-respx.spec ++++++ --- /var/tmp/diff_new_pack.lDGXhx/_old 2024-01-10 21:52:38.652941908 +0100 +++ /var/tmp/diff_new_pack.lDGXhx/_new 2024-01-10 21:52:38.652941908 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-respx # -# Copyright (c) 2023 SUSE LLC +# Copyright (c) 2024 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,14 +17,12 @@ Name: python-respx -Version: 0.20.1 +Version: 0.20.2 Release: 0 Summary: Mock HTTPX with request patterns and response side effects License: BSD-3-Clause URL: https://github.com/lundberg/respx Source0: https://github.com/lundberg/respx/archive/refs/tags/%{version}.tar.gz#/respx-%{version}.tar.gz -# PATCH-FIX-OPENSUSE Use a real IPV6 address to avoid a test failure -Patch0: use-real-ipv6-address.patch BuildRequires: %{python_module Flask} BuildRequires: %{python_module httpx} BuildRequires: %{python_module pytest-asyncio} ++++++ respx-0.20.1.tar.gz -> respx-0.20.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/.github/workflows/check-docs.yml new/respx-0.20.2/.github/workflows/check-docs.yml --- old/respx-0.20.1/.github/workflows/check-docs.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/respx-0.20.2/.github/workflows/check-docs.yml 2023-07-21 00:41:35.000000000 +0200 @@ -0,0 +1,20 @@ +name: check-docs + +on: + pull_request: + paths: + - 'docs/**' + - '.github/workflows/check-docs.yml' + +jobs: + check-docs: + name: Check Docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - run: pip install nox + - name: Run mypy + run: nox -N -s docs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/.github/workflows/docs.yml new/respx-0.20.2/.github/workflows/docs.yml --- old/respx-0.20.1/.github/workflows/docs.yml 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/.github/workflows/docs.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,27 +0,0 @@ -name: docs - -on: - push: - branches: - - master - paths: - - 'docs/**' - -jobs: - build: - name: Build & Publish - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - run: pip install nox - - name: Build - run: nox -N -s docs - - name: Publish - if: github.repository_owner == 'lundberg' - run: | - git config user.email ${{ secrets.GITHUB_EMAIL }} - git remote set-url origin https://${{ secrets.GITHUB_USER }}:${{ secrets.GITHUB_PAGES_TOKEN }}@github.com/lundberg/respx.git - ./.nox/docs/bin/mkdocs gh-deploy --force diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/.github/workflows/lint.yml new/respx-0.20.2/.github/workflows/lint.yml --- old/respx-0.20.1/.github/workflows/lint.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/respx-0.20.2/.github/workflows/lint.yml 2023-07-21 00:41:35.000000000 +0200 @@ -0,0 +1,9 @@ +name: lint + +on: + pull_request: + +jobs: + lint: + name: Check Linting + uses: less-action/reusables/.github/workflows/pre-commit.yaml@v8 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/.github/workflows/publish-docs.yml new/respx-0.20.2/.github/workflows/publish-docs.yml --- old/respx-0.20.1/.github/workflows/publish-docs.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/respx-0.20.2/.github/workflows/publish-docs.yml 2023-07-21 00:41:35.000000000 +0200 @@ -0,0 +1,28 @@ +name: publish-docs + +on: + push: + branches: + - master + paths: + - 'docs/**' + - '.github/workflows/docs.yml' + +jobs: + build: + name: Build & Publish + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10" + - run: pip install nox + - name: Build + run: nox -N -s docs + - name: Publish + if: github.repository_owner == 'lundberg' + run: | + git config user.email ${{ secrets.GITHUB_EMAIL }} + git remote set-url origin https://${{ secrets.GITHUB_USER }}:${{ secrets.GITHUB_PAGES_TOKEN }}@github.com/lundberg/respx.git + ./.nox/docs/bin/mkdocs gh-deploy --force diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/.github/workflows/test.yml new/respx-0.20.2/.github/workflows/test.yml --- old/respx-0.20.1/.github/workflows/test.yml 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/.github/workflows/test.yml 2023-07-21 00:41:35.000000000 +0200 @@ -4,7 +4,11 @@ push: branches: - master + paths-ignore: + - 'docs/**' pull_request: + paths-ignore: + - 'docs/**' env: FORCE_COLOR: 1 @@ -33,10 +37,6 @@ files: ./coverage.xml fail_ci_if_error: true - lint: - name: Check Linting - uses: less-action/reusables/.github/workflows/pre-commit.yaml@v8 - check-types: name: Check Typing runs-on: ubuntu-latest @@ -48,15 +48,3 @@ - run: pip install nox - name: Run mypy run: nox -N -s mypy - - check-docs: - name: Check Docs - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - run: pip install nox - - name: Run mypy - run: nox -N -s docs diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/.pre-commit-config.yaml new/respx-0.20.2/.pre-commit-config.yaml --- old/respx-0.20.1/.pre-commit-config.yaml 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/.pre-commit-config.yaml 2023-07-21 00:41:35.000000000 +0200 @@ -2,7 +2,7 @@ python: python3.11 repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + rev: v4.4.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -13,14 +13,14 @@ - id: debug-statements - id: detect-private-key - repo: https://github.com/asottile/pyupgrade - rev: v3.2.2 + rev: v3.4.0 hooks: - id: pyupgrade args: - --py37-plus - --keep-runtime-typing - repo: https://github.com/pycqa/autoflake - rev: v1.7.7 + rev: v2.1.1 hooks: - id: autoflake args: @@ -28,15 +28,15 @@ - --remove-all-unused-imports - --ignore-init-module-imports - repo: https://github.com/pycqa/isort - rev: 5.10.1 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 23.3.0 hooks: - id: black - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 + rev: 6.0.0 hooks: - id: flake8 additional_dependencies: @@ -47,7 +47,7 @@ - flake8-pytest-style - flake8-datetimez - repo: https://github.com/sirosen/check-jsonschema - rev: 0.19.2 + rev: 0.23.0 hooks: - id: check-github-workflows - repo: https://github.com/asottile/yesqa @@ -62,7 +62,7 @@ - flake8-pytest-style - flake8-datetimez - repo: https://github.com/pre-commit/mirrors-prettier - rev: "v3.0.0-alpha.4" + rev: "v3.0.0-alpha.9-for-vscode" hooks: - id: prettier alias: format-markdown @@ -72,7 +72,7 @@ - --print-width=88 - --prose-wrap=always - repo: https://github.com/mgedmin/check-manifest - rev: "0.48" + rev: "0.49" hooks: - id: check-manifest args: ["--no-build-isolation"] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/CHANGELOG.md new/respx-0.20.2/CHANGELOG.md --- old/respx-0.20.1/CHANGELOG.md 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/CHANGELOG.md 2023-07-21 00:41:35.000000000 +0200 @@ -5,13 +5,30 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.20.2] - 2023-07-21 + +### Fixed + +- Better assertion output for `assert_all_called`, thanks @sileht (#224) +- Support for quoted path pattern matching, thanks @alexdrydew for input (#240) + +### Added + +- Enable content\_\_contains pattern, thanks @rjprins (#236) +- Added initial `CONTRIBUTING.md`, thanks @morenoh149 (#238) + +### Changed + +- Docs about retrieving mocked calls, thanks @tomhamiltonstubber (#230) +- Docs about `Router.assert_all_called()`, thanks @BeyondEvil for input (#241) + ## [0.20.1] - 2022-11-18 ### Fixed - Support HTTPX 0.23.1, thanks @g-as for input (#223) -## Added +### Added - Officially support Python 3.11 (#223) - Run pre-commit hooks in CI workflow (#219) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/CONTRIBUTING.md new/respx-0.20.2/CONTRIBUTING.md --- old/respx-0.20.1/CONTRIBUTING.md 1970-01-01 01:00:00.000000000 +0100 +++ new/respx-0.20.2/CONTRIBUTING.md 2023-07-21 00:41:35.000000000 +0200 @@ -0,0 +1,24 @@ +# Contributing to RESPX + +As an open source project, RESPX welcomes contributions of many forms. + +Examples of contributions include: + +- Code patches +- Documentation improvements +- Bug reports and patch reviews + +## Running Tests + +Tests reside in the `tests/` directory. You can run tests with the +[Task](https://taskfile.dev/installation/) tool from the root of the project. + +- `task test` + +## Linting + +Any contributions should pass the linters setup in this project. + +- `task lint` + +Linters will also be run through github CI on your PR automatically. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/MANIFEST.in new/respx-0.20.2/MANIFEST.in --- old/respx-0.20.1/MANIFEST.in 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/MANIFEST.in 2023-07-21 00:41:35.000000000 +0200 @@ -5,6 +5,7 @@ exclude *.xml exclude flake.* exclude noxfile.py +exclude CONTRIBUTING.md include README.md include CHANGELOG.md include LICENSE.md diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/README.md new/respx-0.20.2/README.md --- old/respx-0.20.1/README.md 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/README.md 2023-07-21 00:41:35.000000000 +0200 @@ -7,7 +7,7 @@ --- -[](https://github.com/lundberg/respx/actions/workflows/test.yml) +[](https://github.com/lundberg/respx/actions/workflows/test.yml) [](https://codecov.io/gh/lundberg/respx) [](https://pypi.org/project/respx/) [](https://pypi.org/project/respx/) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/Taskfile.yaml new/respx-0.20.2/Taskfile.yaml --- old/respx-0.20.1/Taskfile.yaml 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/Taskfile.yaml 2023-07-21 00:41:35.000000000 +0200 @@ -14,11 +14,11 @@ - task: lint test: - desc: Run single test suite + desc: Run test suite against latest python label: test -- [pytest options] silent: true deps: [tools] - cmds: [".venv/bin/nox -R -s test-3.10 -- {{.CLI_ARGS}}"] + cmds: [".venv/bin/nox -R -s test-3.11 -- {{.CLI_ARGS}}"] mypy: desc: Statically type check python files diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/docs/api.md new/respx-0.20.2/docs/api.md --- old/respx-0.20.1/docs/api.md 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/docs/api.md 2023-07-21 00:41:35.000000000 +0200 @@ -301,10 +301,11 @@ ### Content Matches request raw *content*, using [eq](#eq) as default lookup. > Key: `content` -> Lookups: [eq](#eq) +> Lookups: [eq](#eq), [contains](#contains) ``` python respx.post("https://example.org/", content="foobar") respx.post("https://example.org/", content=b"foobar") +respx.post("https://example.org/", content__contains="bar") ``` ### Data diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/docs/guide.md new/respx-0.20.2/docs/guide.md --- old/respx-0.20.1/docs/guide.md 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/docs/guide.md 2023-07-21 00:41:35.000000000 +0200 @@ -623,7 +623,6 @@ ``` python import httpx import respx -from respx.transports import MockTransport router = respx.Router() @@ -635,10 +634,20 @@ with httpx.Client(transport=mock_transport) as client: response = client.post("https://example.org/") assert response.status_code == 404 + + +def test_client(): + mock_transport = httpx.MockTransport(router.async_handler) + with httpx.AsyncClient(transport=mock_transport) as client: + ... ``` + !!! note "NOTE" - Use `httpx.MockTransport(router.async_handler)` when using an `httpx.AsyncClient`. + To assert all routes is called, you'll need to trigger + `<router>.assert_all_called()` manually, e.g. in a test case or after yielding the + router in a *pytest* fixture, since there's no auto post assertion done like + when using [respx.mock](#assert-all-called). !!! Hint You can use `RESPX` not only to mock out `HTTPX`, but actually mock any library using `HTTP Core` transports. @@ -672,7 +681,10 @@ ``` python last_request = respx.calls.last.request -assert respx.calls.last.response.status_code == 200 +assert json.loads(last_request.content) == {"foo": "bar"} + +last_response = respx.calls.last.response +assert last_response.status_code == 200 ``` ### Local route calls diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/docs/index.md new/respx-0.20.2/docs/index.md --- old/respx-0.20.1/docs/index.md 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/docs/index.md 2023-07-21 00:41:35.000000000 +0200 @@ -10,7 +10,7 @@ Mock [HTTPX](https://www.python-httpx.org/) with awesome request patterns and response side effects. -[](https://github.com/lundberg/respx/actions/workflows/test.yml) [](https://codecov.io/gh/lundberg/respx) [](https://pypi.org/project/respx/) [](https://pypi.org/project/respx/) +[](https://github.com/lundberg/respx/actions/workflows/test.yml) [](https://codecov.io/gh/lundberg/respx) [](https://pypi.org/project/respx/) [](https://pypi.org/project/respx/) ## QuickStart diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/flake.lock new/respx-0.20.2/flake.lock --- old/respx-0.20.1/flake.lock 1970-01-01 01:00:00.000000000 +0100 +++ new/respx-0.20.2/flake.lock 2023-07-21 00:41:35.000000000 +0200 @@ -0,0 +1,94 @@ +{ + "nodes": { + "flakeUtils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1684266851, + "narHash": "sha256-DCYaTgZpT9BtHrVEJOc1b0J/8eTDa1SRqyGbcisjauM=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5b973b9f07c586dfade51f6736db166f5b97d97c", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs22": { + "locked": { + "lastModified": 1669833724, + "narHash": "sha256-/HEZNyGbnQecrgJnfE8d0WC5c1xuPSD2LUpB6YXlg4c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "4d2b37a84fad1091b9de401eb450aae66f1a741e", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgsUnstable": { + "locked": { + "lastModified": 1684242266, + "narHash": "sha256-uaCQ2k1bmojHKjWQngvnnnxQJMY8zi1zq527HdWgQf8=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "7e0743a5aea1dc755d4b761daf75b20aa486fdad", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flakeUtils": "flakeUtils", + "nixpkgs": "nixpkgs", + "nixpkgs22": "nixpkgs22", + "nixpkgsUnstable": "nixpkgsUnstable" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/flake.nix new/respx-0.20.2/flake.nix --- old/respx-0.20.1/flake.nix 1970-01-01 01:00:00.000000000 +0100 +++ new/respx-0.20.2/flake.nix 2023-07-21 00:41:35.000000000 +0200 @@ -0,0 +1,42 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs"; + nixpkgs22.url = "github:nixos/nixpkgs/22.11"; + nixpkgsUnstable.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + flakeUtils.url = "github:numtide/flake-utils"; + }; + outputs = { self, nixpkgs, nixpkgs22, nixpkgsUnstable, flakeUtils }: + flakeUtils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + pkgs22 = nixpkgs22.legacyPackages.${system}; + pkgsUnstable = nixpkgsUnstable.legacyPackages.${system}; + in { + packages = flakeUtils.lib.flattenTree { + python311 = pkgs.python311; + python310 = pkgs.python310; + python39 = pkgs.python39; + python38 = pkgs.python38; + python37 = pkgs22.python37; + go-task = pkgsUnstable.go-task; + }; + devShell = pkgs.mkShell { + buildInputs = with self.packages.${system}; [ + python311 + python310 + python39 + python38 + python37 + go-task + ]; + shellHook = '' + [[ ! -d .venv ]] && \ + echo "Creating virtualenv ..." && \ + ${pkgs.python310}/bin/python -m \ + venv --copies --upgrade-deps .venv > /dev/null + source .venv/bin/activate + ''; + }; + } + ); +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/respx/__version__.py new/respx-0.20.2/respx/__version__.py --- old/respx-0.20.1/respx/__version__.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/respx/__version__.py 2023-07-21 00:41:35.000000000 +0200 @@ -1 +1 @@ -__version__ = "0.20.1" +__version__ = "0.20.2" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/respx/models.py new/respx-0.20.2/respx/models.py --- old/respx-0.20.1/respx/models.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/respx/models.py 2023-07-21 00:41:35.000000000 +0200 @@ -102,12 +102,13 @@ if content is not None: kwargs["content"] = content + if http_version: + kwargs["extensions"] = kwargs.get("extensions", {}) + kwargs["extensions"]["http_version"] = http_version.encode("ascii") super().__init__(status_code or 200, **kwargs) if content_type: self.headers["Content-Type"] = content_type - if http_version: - self.extensions["http_version"] = http_version.encode("ascii") class Route: @@ -510,10 +511,6 @@ pass -class AllCalledAssertionError(AssertionError): - pass - - class SideEffectError(Exception): def __init__(self, route: Route, origin: Exception) -> None: self.route = route diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/respx/patterns.py new/respx-0.20.2/respx/patterns.py --- old/respx-0.20.1/respx/patterns.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/respx/patterns.py 2023-07-21 00:41:35.000000000 +0200 @@ -413,7 +413,16 @@ self, value: Union[str, RegexPattern[str]] ) -> Union[str, RegexPattern[str]]: if self.lookup in (Lookup.EQUAL, Lookup.STARTS_WITH) and isinstance(value, str): - path = urljoin("/", value) # Ensure leading slash + # Percent encode path, i.e. revert parsed path by httpx.URL. + # Borrowed from HTTPX's "private" quote and percent_encode utilities. + path = "".join( + char + if char + in "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~/" + else "".join(f"%{byte:02x}" for byte in char.encode("utf-8")).upper() + for char in value + ) + path = urljoin("/", path) # Ensure leading slash value = httpx.URL(path).path elif self.lookup is Lookup.REGEX and isinstance(value, str): value = re.compile(value) @@ -483,7 +492,7 @@ class Content(ContentMixin, Pattern): - lookups = (Lookup.EQUAL,) + lookups = (Lookup.EQUAL, Lookup.CONTAINS) key = "content" value: bytes @@ -492,6 +501,9 @@ return value.encode() return value + def _contains(self, value: Union[bytes, str]) -> Match: + return Match(self.value in value) + class JSON(ContentMixin, PathPattern): lookups = (Lookup.EQUAL,) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/respx/router.py new/respx-0.20.2/respx/router.py --- old/respx-0.20.1/respx/router.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/respx/router.py 2023-07-21 00:41:35.000000000 +0200 @@ -21,7 +21,6 @@ from .mocks import Mocker from .models import ( - AllCalledAssertionError, AllMockedAssertionError, CallList, PassThrough, @@ -99,8 +98,8 @@ route.reset() def assert_all_called(self) -> None: - if any(not route.called for route in self.routes): - raise AllCalledAssertionError("RESPX: some routes were not called!") + not_called_routes = [route for route in self.routes if not route.called] + assert not_called_routes == [], "RESPX: some routes were not called!" def __getitem__(self, name: str) -> Route: return self.routes[name] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/respx/transports.py new/respx-0.20.2/respx/transports.py --- old/respx-0.20.1/respx/transports.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/respx/transports.py 2023-07-21 00:41:35.000000000 +0200 @@ -2,8 +2,8 @@ from typing import ( TYPE_CHECKING, Any, - Awaitable, Callable, + Coroutine, List, Optional, Type, @@ -21,7 +21,7 @@ from .router import Router # pragma: nocover RequestHandler = Callable[[httpx.Request], httpx.Response] -AsyncRequestHandler = Callable[[httpx.Request], Awaitable[httpx.Response]] +AsyncRequestHandler = Callable[[httpx.Request], Coroutine[None, None, httpx.Response]] class MockTransport(httpx.MockTransport): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/tests/test_api.py new/respx-0.20.2/tests/test_api.py --- old/respx-0.20.1/tests/test_api.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/tests/test_api.py 2023-07-21 00:41:35.000000000 +0200 @@ -82,6 +82,7 @@ ("https://foo.bar/baz/", re.compile(r"^https://foo.bar/\w+/$")), ("https://foo.bar/baz/", (b"https", b"foo.bar", None, b"/baz/")), ("https://foo.bar:443/baz/", (b"https", b"foo.bar", 443, b"/baz/")), + ("https://foo.bar/%08", "https://foo.bar/%08"), ], ) async def test_url_match(client, url, pattern): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/tests/test_mock.py new/respx-0.20.2/tests/test_mock.py --- old/respx-0.20.1/tests/test_mock.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/tests/test_mock.py 2023-07-21 00:41:35.000000000 +0200 @@ -7,7 +7,7 @@ import respx from respx import ASGIHandler, WSGIHandler from respx.mocks import Mocker -from respx.models import AllCalledAssertionError, AllMockedAssertionError +from respx.models import AllMockedAssertionError from respx.router import MockRouter @@ -405,7 +405,11 @@ @pytest.mark.parametrize( ("assert_all_called", "do_post", "raises"), [ - (True, False, pytest.raises(AllCalledAssertionError)), + ( + True, + False, + pytest.raises(AssertionError, match="some routes were not called"), + ), (True, True, does_not_raise()), (False, True, does_not_raise()), (False, False, does_not_raise()), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/tests/test_patterns.py new/respx-0.20.2/tests/test_patterns.py --- old/respx-0.20.1/tests/test_patterns.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/tests/test_patterns.py 2023-07-21 00:41:35.000000000 +0200 @@ -280,9 +280,9 @@ (Lookup.STARTS_WITH, "http://a.b/baz/", {}, "https://a.b/baz/", False), ( Lookup.EQUAL, - (b"https", b"fake:ipv6", None, b""), + (b"https", b"FE80::1", None, b""), {}, - "https://[fake:ipv6]", + "https://[FE80::1]", True, ), ], @@ -311,6 +311,9 @@ [ (Lookup.EQUAL, b"foobar", True), (Lookup.EQUAL, "foobar", True), + (Lookup.CONTAINS, b"bar", True), + (Lookup.CONTAINS, "bar", True), + (Lookup.CONTAINS, "baz", False), ], ) def test_content_pattern(lookup, content, expected): @@ -450,7 +453,7 @@ pattern = Method("GET") & Path("/spam/") base = Path("/ham/", Lookup.STARTS_WITH) merged_pattern = merge_patterns(pattern, path=base) - assert any([p.base == base for p in iter(merged_pattern)]) + assert any(tuple(p.base == base for p in iter(merged_pattern))) def test_unique_pattern_key(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/respx-0.20.1/tests/test_transports.py new/respx-0.20.2/tests/test_transports.py --- old/respx-0.20.1/tests/test_transports.py 2022-11-18 17:58:50.000000000 +0100 +++ new/respx-0.20.2/tests/test_transports.py 2023-07-21 00:41:35.000000000 +0200 @@ -3,7 +3,7 @@ import httpx import pytest -from respx.models import AllCalledAssertionError, PassThrough +from respx.models import PassThrough from respx.router import Router from respx.transports import MockTransport @@ -57,7 +57,9 @@ transport = MockTransport(router=router) assert len(w) == 1 - with pytest.raises(AllCalledAssertionError, match="not called"): # noqa [PT012] + with pytest.raises( # noqa [PT012] + AssertionError, match="some routes were not called" + ): async with httpx.AsyncClient(transport=transport) as client: response = await client.get(url) assert response.status_code == 404
