Message382634
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 |
|
Date |
User |
Action |
Args |
2020-12-07 13:31:34 | valeriupredoi | set | recipients:
+ valeriupredoi |
2020-12-07 13:31:34 | valeriupredoi | set | messageid: <1607347894.15.0.455977385218.issue42586@roundup.psfhosted.org> |
2020-12-07 13:31:34 | valeriupredoi | link | issue42586 messages |
2020-12-07 13:31:34 | valeriupredoi | create | |
|