Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SharedMocks returned by QuerySetMock are missing assertion methods #22

Open
boydjj opened this issue Aug 24, 2013 · 0 comments
Open

SharedMocks returned by QuerySetMock are missing assertion methods #22

boydjj opened this issue Aug 24, 2013 · 0 comments

Comments

@boydjj
Copy link
Contributor

boydjj commented Aug 24, 2013

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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant