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

Method test_false_len_iterable

numpy/core/tests/test_multiarray.py:1092–1106  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1090 assert_equal(len(a), 0)
1091
1092 def test_false_len_iterable(self):
1093 # Special case where a bad __getitem__ makes us fall back on __iter__:
1094 class C:
1095 def __getitem__(self, x):
1096 raise Exception
1097 def __iter__(self):
1098 return iter(())
1099 def __len__(self):
1100 return 2
1101
1102 a = np.empty(2)
1103 with assert_raises(ValueError):
1104 a[:] = C() # Segfault!
1105
1106 np.array(C()) == list(C())
1107
1108 def test_failed_len_sequence(self):
1109 # gh-7393

Callers

nothing calls this directly

Calls 2

assert_raisesFunction · 0.90
CClass · 0.70

Tested by

no test coverage detected