New submission from Dylan Semler <dylan.sem...@gmail.com>: 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=('a', 'tuple')) dir(mock) 🡒 python3 poc.py Traceback (most recent call last): File "poc.py", line 4, in <module> dir(mock) File "/usr/lib64/python3.6/unittest/mock.py", line 677, in __dir__ return sorted(set(extras + from_type + from_dict + TypeError: can only concatenate tuple (not "list") to tuple ---------- components: Library (Lib) messages: 339813 nosy: Dylan Semler priority: normal severity: normal status: open title: __dir__ on unittest.mock not safe for all spec types type: crash versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36581> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com