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.

TypeError: cannot unpack non-iterable CallbackResponse object

See original GitHub issue

After upgrading from responses 0.12.0 to 0.12.1 our unit tests fail with the following error:

...

../../../../venv/lib/python3.8/site-packages/requests/sessions.py:590: in post
    return self.request('POST', url, data=data, json=json, **kwargs)
../../../../venv/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py:515: in request
    return super(OAuth2Session, self).request(
../../../../venv/lib/python3.8/site-packages/aws_xray_sdk/ext/requests/patch.py:27: in _xray_traced_requests
    return xray_recorder.record_subsegment(
../../../../venv/lib/python3.8/site-packages/aws_xray_sdk/core/recorder.py:424: in record_subsegment
    return_value = wrapped(*args, **kwargs)
../../../../venv/lib/python3.8/site-packages/requests/sessions.py:542: in request
    resp = self.send(prep, **send_kwargs)
../../../../venv/lib/python3.8/site-packages/requests/sessions.py:655: in send
    r = adapter.send(request, **kwargs)
../../../../venv/lib/python3.8/site-packages/responses.py:733: in unbound_on_send
    return self._on_request(adapter, request, *a, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <responses.RequestsMock object at 0x104e06880>
adapter = <requests.adapters.HTTPAdapter object at 0x10a7a8a00>
request = <PreparedRequest [POST]>
kwargs = {'cert': None, 'proxies': OrderedDict(), 'stream': False, 'timeout': 10, ...}

    def _on_request(self, adapter, request, **kwargs):
>       match, match_failed_reasons = self._find_match(request)
E       TypeError: cannot unpack non-iterable CallbackResponse object

../../../../venv/lib/python3.8/site-packages/responses.py:680: TypeError

This seems to have been caused by the refactoring of the Response._find_match() method.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:19 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
philhoff-edekacommented, Nov 12, 2020

@hramezani I’ve also tried to create a minimal example for you. It passes on my machine when I use responses version 0.12.0 and fails when I upgrade to 0.12.1:

# coding=utf-8
import responses
from requests_oauthlib import OAuth2Session


@responses.activate
def test_response():
    # given
    responses.add(
        method = responses.POST,
        url = "https://example.com/",
        body = "expected",
        status = 200
    )

    # when
    oauth_session = OAuth2Session()
    response = oauth_session.post(
        url = "https://example.com/",
        data = "actual"
    )

    # then
    assert len(responses.calls) == 1
    assert responses.calls[0].request.url == "https://example.com/"
    assert responses.calls[0].request.body == "actual"
    assert response.text == "expected"

2reactions
hramezanicommented, Nov 12, 2020

I created a PR(https://github.com/getsentry/responses/pull/359) to address this problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: TypeError: cannot unpack non-iterable int object
The error due to variable assignment. def maxsum(arry): if len(arry)==0: return 0 summ ...
Read more >
TypeError cannot unpack non-iterable NoneType object
The “TypeError: cannot unpack non-iterable NoneType object” error is raised when you try to unpack values from one that is equal to None....
Read more >
Typeerror: cannot unpack non-iterable nonetype object
During the process of unpacking items in iterable objects, you may get an error that says: "TypeError: cannot unpack non-iterable NoneType ...
Read more >
TypeError: cannot unpack non-iterable NoneType object
The Python TypeError: cannot unpack non-iterable NoneType object error is raised when you try to unpack a None value. On Career Karma, learn ......
Read more >
Why am I getting an 'TypeError: cannot unpack non-iterable int ...
When you use the for i,j in item syntax, Python is expecting that item is an iterable of iterables, which can be unpacked...
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