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

Mocking an iterable object produces a non-iterable mock object #5

Closed
GoogleCodeExporter opened this issue Apr 21, 2015 · 2 comments
Closed

Comments

@GoogleCodeExporter
Copy link

I've seen this happen with some parts of django (djangoproject.com), as well as 
homebrew 
iterable objects.

Calling

mock = Mock(spec=IterableClass)

will indeed provide a mock object made of that class, but trying things like

"a" in mock

will cause an exception as follows:

"TypeError: argument of type 'Mock' is not iterable"

Original issue reported on code.google.com by chris.we...@gmail.com on 18 Aug 2008 at 9:46

@GoogleCodeExporter
Copy link
Author

Mock doesn't currently attempt to mock iterables. It's a worthy feature request 
though.

Original comment by fuzzyman on 18 Aug 2008 at 8:10

  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

The latest version of Mock in subversion supports iteration (and subscription). 
No
docs yet, see the tests for details.

Original comment by fuzzyman on 31 Oct 2008 at 11:19

  • Changed state: Fixed

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