Skip to content

Mocked requests are more permissive with args, causing tests to pass when they should fail #39

@furmaniak

Description

@furmaniak

I ran into this issue today, where everything worked in tests but failed when not mocked.

>>> import requests
>>> requests.post('http://example.com', 2.0)
TypeError: 'float' object is not iterable

Compare to

>>> import requests
>>> import httmock
>>> with httmock.HTTMock(lambda url, req: ''): requests.post('http://example.com', 2.0)
<Response [200]>

This is because 2.0 becomes the value of data, which must be iterable in requests, but can be anything in _fake_send, Putting in a type check for data would at least fix this (perhaps most common variant) even if it's not perfect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions