dcramer/mock-django

SharedMocks returned by QuerySetMock are missing assertion methods

boydjj opened this issue · 0 comments

As of #20, QuerySet-returning methods on SharedMocks returned by QuerySetMock no longer have normal Mock-like behaviors:

>>> from django.conf import settings
>>> settings.configure()
>>> from mock_django.query import QuerySetMock
>>> qs = QuerySetMock(None, 1, 2, 3)
>>> qs.filter.assert_called_with('boo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'assert_called_with'

This is a regression, since this worked as of c45d4c8:

>>> from django.conf import settings
>>> settings.configure()
>>> from mock_django.query import QuerySetMock
>>> qs = QuerySetMock(None, 1, 2, 3)
>>> qs.filter.assert_called_with('boo')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jboyd/envs/mock-django/lib/python2.7/site-packages/mock.py", line 831, in assert_called_with
    raise AssertionError('Expected call: %s\nNot called' % (expected,))
AssertionError: Expected call: filter('boo')
Not called
>>> qs.filter('boo')
<generator object _iterator at 0x10ba334b0>
>>> qs.filter.assert_called_with('boo')