MCPcopy Create free account
hub / github.com/numpy/numpy / test_setstate

Method test_setstate

numpy/core/tests/test_datetime.py:843–849  ·  view source on GitHub ↗

Verify that datetime dtype __setstate__ can handle bad arguments

(self)

Source from the content-addressed store, hash-verified

841 assert_equal(pickle.loads(pkl), np.dtype('>M8[us]'))
842
843 def test_setstate(self):
844 "Verify that datetime dtype __setstate__ can handle bad arguments"
845 dt = np.dtype('>M8[us]')
846 assert_raises(ValueError, dt.__setstate__, (4, '>', None, None, None, -1, -1, 0, 1))
847 assert_(dt.__reduce__()[2] == np.dtype('>M8[us]').__reduce__()[2])
848 assert_raises(TypeError, dt.__setstate__, (4, '>', None, None, None, -1, -1, 0, ({}, 'xxx')))
849 assert_(dt.__reduce__()[2] == np.dtype('>M8[us]').__reduce__()[2])
850
851 def test_dtype_promotion(self):
852 # datetime <op> datetime computes the metadata gcd

Callers

nothing calls this directly

Calls 4

assert_raisesFunction · 0.90
assert_Function · 0.90
dtypeMethod · 0.45
__reduce__Method · 0.45

Tested by

no test coverage detected