This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author valeriupredoi
Recipients valeriupredoi
Date 2020-12-07.13:31:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1607347894.15.0.455977385218.issue42586@roundup.psfhosted.org>
In-reply-to
Content
Hey guys, the new unittest.mock.Mock for Python 3.9 can not accept a spec arg if it is a numpy array, it'll accept all other types but not ndarray, have a look at this quick minimal code:

import numpy as np

from unittest import mock as mg

ob = mg.Mock(spec=[4, 4])
print("spec is list, mock is", ob)

ob = mg.Mock(spec=["4", "4"])
print("spec is list of str, mock is", ob)

ob = mg.Mock(spec=(4, 4))
print("spec is tuple, mock is", ob)

ob = mg.Mock(spec="cow")
print("spec is string, mock is", ob)

ob = mg.Mock(spec=22)
print("spec is int, mock is", ob)

ob = mg.Mock(spec=np.array([4, 4]))
print("spec is ndarray, mock is", ob)

versions:
python  3.9.0 h2a148a8_4_cpython    conda-forge
pytest-mock 3.3.1  pypi_0    pypi

Is this intended or it's a buggy-bug?

Cheers muchly! V
History
Date User Action Args
2020-12-07 13:31:34valeriupredoisetrecipients: + valeriupredoi
2020-12-07 13:31:34valeriupredoisetmessageid: <1607347894.15.0.455977385218.issue42586@roundup.psfhosted.org>
2020-12-07 13:31:34valeriupredoilinkissue42586 messages
2020-12-07 13:31:34valeriupredoicreate