Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getsentry/responses
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.23.3
Choose a base ref
...
head repository: getsentry/responses
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.24.0
Choose a head ref

Commits on Aug 1, 2023

  1. Merge branch 'release/0.23.3'

    getsentry-bot committed Aug 1, 2023
    Copy the full SHA
    ad22f54 View commit details

Commits on Aug 22, 2023

  1. [#651] regex compatability for headers matching (#663)

    * [#651] regex compatability for headers matching
    
    * [#651] Adding test for strict with regex
    
    * [#651] Simplifying logic + tests for various sub cases
    
    * [#651] Refactoring test cases in to TestHeaderWithRegex class
    
    * [#651] Making url a property in test class
    geetptl authored Aug 22, 2023
    Copy the full SHA
    e5a6159 View commit details
  2. Update changelog

    markstory committed Aug 22, 2023
    Copy the full SHA
    771477f View commit details

Commits on Aug 24, 2023

  1. Copy the full SHA
    3e7913b View commit details
  2. Support gzipped request.body in json_params_matcher (#665)

    * Support gzipped request.body in json_params_matcher
    * fix mypy issue with gzip.decompress arg-type
    haakonvt authored Aug 24, 2023
    Copy the full SHA
    dc857cd View commit details
  3. Update changelog for #665

    markstory committed Aug 24, 2023
    Copy the full SHA
    474268d View commit details
  4. Copy the full SHA
    3ee9882 View commit details
  5. Update changelog for #667

    markstory committed Aug 24, 2023
    Copy the full SHA
    a3ad567 View commit details
  6. Fix linting error.

    markstory committed Aug 24, 2023
    Copy the full SHA
    10d0473 View commit details

Commits on Sep 25, 2023

  1. fix mypy issue (#674)

    beliaev-maksim authored Sep 25, 2023
    Copy the full SHA
    a7d76ce View commit details
  2. Revert "fix mypy issue (#674)" (#676)

    This reverts commit a7d76ce.
    beliaev-maksim authored Sep 25, 2023
    Copy the full SHA
    cf05e41 View commit details

Commits on Oct 4, 2023

  1. Added real_adapter_send parameter to RequestsMock (#671)

    * Added `real_adapter_send` parameter to `RequestsMock` that will allow users to set
      through which function they would like to send real requests
    beliaev-maksim authored Oct 4, 2023
    Copy the full SHA
    0f54001 View commit details
  2. fix coverage on master (#677)

    * change the order of dependencies installation to ensure that `urllib3` is not overwritten
    beliaev-maksim authored Oct 4, 2023
    Copy the full SHA
    9c0d1ac View commit details

Commits on Oct 6, 2023

  1. Copy the full SHA
    923307c View commit details

Commits on Oct 21, 2023

  1. Copy the full SHA
    30e49a4 View commit details
  2. fix types (#684)

    * remove dependency on urllib3 vendored in requests since it is not maintained anymore. See python/typeshed#6893 (comment)
    * new version of mypy does not require overloads for type checking
    * [skip] remove pragma comment
    beliaev-maksim authored Oct 21, 2023
    Copy the full SHA
    74466ec View commit details

Commits on Oct 23, 2023

  1. updated _form_response function with more native handling by utiliz…

    …ing the correct `HTTPResponse` from `http` rather than from `urllib3` (#685)
    beliaev-maksim authored Oct 23, 2023
    Copy the full SHA
    87db9df View commit details
  2. Copy the full SHA
    5c6a3b1 View commit details

Commits on Oct 30, 2023

  1. Calls info in BaseResponse (#664)

    * Add calls to BaseResponse
    * Reuse calls for matched BaseResponse and add add_call method into CallList
    * Reuse call object with add_call & add example of usage Response.calls into README
    
    Co-authored-by: Maksim Beliaev <beliaev.m.s@gmail.com>
    zeezdev and beliaev-maksim authored Oct 30, 2023
    Copy the full SHA
    bcad0cd View commit details
  2. Copy the full SHA
    9d38e6e View commit details

Commits on Nov 3, 2023

  1. release: 0.24.0

    getsentry-bot committed Nov 3, 2023
    Copy the full SHA
    5579f8e View commit details
Showing with 482 additions and 141 deletions.
  1. +2 −2 .github/workflows/ci.yml
  2. +6 −1 .pre-commit-config.yaml
  3. +13 −1 CHANGES
  4. +54 −1 README.rst
  5. +100 −99 responses/__init__.py
  6. +28 −6 responses/matchers.py
  7. +2 −4 responses/registries.py
  8. +175 −0 responses/tests/test_matchers.py
  9. +1 −1 responses/tests/test_recorder.py
  10. +97 −20 responses/tests/test_responses.py
  11. +3 −5 setup.py
  12. +1 −1 tox.ini
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11']
requests-version: ['"requests>=2.0,<3.0"']
urllib3-version: ['"urllib3<2"', '"urllib3>=2,<3.0"']

@@ -48,8 +48,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ${{ matrix.requests-version }} ${{ matrix.urllib3-version }}
make install-deps
pip install ${{ matrix.requests-version }} ${{ matrix.urllib3-version }}
- name: Run Pytest
run: |
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -25,7 +25,12 @@ repos:
hooks:
- id: flake8
args: [ '--max-line-length', '100', '--max-doc-length', '120' ]
- repo: https://github.com/asottile/blacken-docs
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
hooks:
- id: pyupgrade
args: [--py37-plus]
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.14.0
hooks:
- id: blacken-docs
14 changes: 13 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
0.24.0
------

* Added `BaseResponse.calls` to access calls data of a separate mocked request. See #664
* Added `real_adapter_send` parameter to `RequestsMock` that will allow users to set
through which function they would like to send real requests
* Added support for re.Pattern based header matching.
* Added support for gzipped response bodies to `json_params_matcher`.
* Fix `Content-Type` headers issue when the header was duplicated. See #644
* Moved types-pyyaml dependency to `tests_requires`
* Removed Python3.7 support

0.23.3
------

* Allow urllib3>=1.25.10
* Allow urllib3>=1.25.10


0.23.2
55 changes: 54 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ A utility library for mocking out the ``requests`` Python library.

.. note::

Responses requires Python 3.7 or newer, and requests >= 2.30.0
Responses requires Python 3.8 or newer, and requests >= 2.30.0


Table of Contents
@@ -1079,6 +1079,59 @@ Assert that the request was called exactly n times.
responses.assert_call_count("http://www.example.com?hello=world", 1) is True
Assert Request Calls data
-------------------------

``Request`` object has ``calls`` list which elements correspond to ``Call`` objects
in the global list of ``Registry``. This can be useful when the order of requests is not
guaranteed, but you need to check their correctness, for example in multithreaded
applications.

.. code-block:: python
import concurrent.futures
import responses
import requests
@responses.activate
def test_assert_calls_on_resp():
rsp1 = responses.patch("http://www.foo.bar/1/", status=200)
rsp2 = responses.patch("http://www.foo.bar/2/", status=400)
rsp3 = responses.patch("http://www.foo.bar/3/", status=200)
def update_user(uid, is_active):
url = f"http://www.foo.bar/{uid}/"
response = requests.patch(url, json={"is_active": is_active})
return response
with concurrent.futures.ThreadPoolExecutor(max_workers=3) as executor:
future_to_uid = {
executor.submit(update_user, uid, is_active): uid
for (uid, is_active) in [("3", True), ("2", True), ("1", False)]
}
for future in concurrent.futures.as_completed(future_to_uid):
uid = future_to_uid[future]
response = future.result()
print(f"{uid} updated with {response.status_code} status code")
assert len(responses.calls) == 3 # total calls count
assert rsp1.call_count == 1
assert rsp1.calls[0] in responses.calls
assert rsp1.calls[0].response.status_code == 200
assert json.loads(rsp1.calls[0].request.body) == {"is_active": False}
assert rsp2.call_count == 1
assert rsp2.calls[0] in responses.calls
assert rsp2.calls[0].response.status_code == 400
assert json.loads(rsp2.calls[0].request.body) == {"is_active": True}
assert rsp3.call_count == 1
assert rsp3.calls[0] in responses.calls
assert rsp3.calls[0].response.status_code == 200
assert json.loads(rsp3.calls[0].request.body) == {"is_active": True}
Multiple Responses
------------------

Loading