question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

0.17.0 blocks moto and httpretty interop

See original GitHub issue

We have tests that utilize httpretty and moto but the 0.17.0 update causes the following error:

requests.exceptions.ConnectionError: Connection refused by Responses - the call doesn’t match any registered mock.

This is true because our internal calls are not an AWS destination and are mocked by httpretty.

Pinning back to 0.16.0 resolved the issue

  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.6/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/responses/__init__.py", line 842, in unbound_on_send
    return self._on_request(adapter, request, *a, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/responses/__init__.py", line 821, in _on_request
    raise response
requests.exceptions.ConnectionError: Connection refused by Responses - the call doesn't match any registered mock.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bblommerscommented, Jan 12, 2022

@davetrollope Moto has just released a new version, 2.3.2.dev2, that works with all versions of responses. If you do run into any other issues with the latest version, feel free to raise them in Moto’s repo: https://github.com/spulec/moto/issues/4750

@beliaev-maksim Appreciate the offer! Looks like everything is sorted now. With 0.17.0, we no longer have to touch any of the internal API’s, so that always a good sign 🙂

On a janitorial note: It looks like ResponsesMock._matches is no longer used anywhere: https://github.com/getsentry/responses/blob/6e7d4669c1a0bb236747111fc8e9502c281d7fcf/responses/__init__.py#L524 If you want, I can raise a PR to remove this field?

1reaction
bblommerscommented, Jan 11, 2022

Are you using an pass through prefixes to exclude responses from attempting to handle specific requests?

Moto maintainer here - yes, we do. This was our setup in 0.16:

responses_mock = responses.RequestsMock(assert_all_requests_are_fired=False)
responses_mock.add_passthru("http")

A reproducible usecase using Moto would be:

@moto.mock_sqs
def test_passthrough_requests():
    conn = boto3.client("sqs", region_name="us-west-1")
    conn.create_queue(QueueName="queue1")

    res = requests.get("https://httpbin.org/ip")
    assert res.status_code == 200

So the first request (hiding behind conn.create_queue() would be intercepted by responses, because our decorator has created a mock for it, but the second request should go through.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTPretty's - HTTP Client Mocking for Python — HTTPretty 1.1 ...
https://github.com/gabrielfalcao/HTTPretty/raw/master/. HTTP Client mocking tool for Python created by Gabriel Falcão . It provides a full fake TCP socket ...
Read more >
main - Anaconda repo
Package Latest Version Doc Dev License linux‑64 osx‑64 win‑64 7za 920 doc LGPL X 7zip 19.00 dev LGPL‑2.1‑or‑later X _anaconda_depends 2022.05 doc dev BSD X X...
Read more >
Cron <root@ppc-hub> /usr/local/bin/do-compare.sh
... only remote: eclipse-m2e-mavenarchiver-0.17.0-0.3.git0a4e929.fc24 ... only remote: libopensync-plugin-moto-0.22-13.fc24 only remote: ...
Read more >
Sync-friendly git mirror of repo/gentoo with caches and metadata
... defining the SPICE protocol app-emulation/spice-vdagent 0.17.0: SPICE VD ... deleted files in block devices app-forensics/memdump 1.01: Simple memory ...
Read more >
Package list with short descriptions
2048-cli-0.9.1 terminal version of the 2048 sliding block puzzle game. 2bwm-0.3 fast floating window manager ... coldfire-0.3.1p2 Motorola Coldfire emulator.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found