patrys / httmock

A mocking library for requests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No longer works with mock objects

jimrollenhagen opened this issue · comments

The 1.1.0 release no longer works when used as the return value for a mock object.

Failing test case:

class PutTest(unittest.TestCase):
    def test_put(self):
        res = httmock.response(status_code=204)
        put_mock = mock.Mock()
        put_mock.return_value = res
        response = put_mock('http://example.org', data={'foo', 'bar'})

Fails with an exception:

======================================================================
ERROR: test_put (main.PutTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jimrollenhagen/code/httmock-bug/main.py", line 13, in test_put
    res = httmock.response(status_code=204)
  File "/Users/jimrollenhagen/virtualenvs/httmockbug/lib/python2.7/site-packages/httmock.py", line 43, in response
    res.url = request.url
AttributeError: 'NoneType' object has no attribute 'url'

----------------------------------------------------------------------

Forgive me my lord for I have failed you. Brown paper bag release 1.1.1 has been pushed to pypi.

Awesome, thanks!