[issue36581] __dir__ on unittest.mock not safe for all spec types

2019-04-09 Thread Dylan Semler
Dylan Semler added the comment: I agree docs only say "list of strings" and so this isn't a case where there's behavior that contrasts with the documentation. I merely ran into this issue in my project and found it difficult to get to the root of so wanted to fix it upstream. I ma

[issue36581] __dir__ on unittest.mock not safe for all spec types

2019-04-09 Thread Dylan Semler
New submission from Dylan Semler : If a MagicMock is created with a spec or spec_set that is a non-list iterable of strings (like a tuple), calling dir() on said mock produces a Traceback. Here's a minimum example:  cat poc.py from unittest.mock import MagicMock mock = MagicMock(spec