MCPcopy Index your code
hub / github.com/python/cpython / test_ndarray_random_invalid

Method test_ndarray_random_invalid

Lib/test/test_buffer.py:1940–1966  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1938 lst=z.tolist())
1939
1940 def test_ndarray_random_invalid(self):
1941 # exceptions during construction of invalid arrays
1942 for _ in range(ITERATIONS):
1943 for fmt in fmtdict['@']:
1944 itemsize = struct.calcsize(fmt)
1945
1946 t = rand_structure(itemsize, False, maxdim=MAXDIM,
1947 maxshape=MAXSHAPE)
1948 self.assertFalse(verify_structure(*t))
1949 items = randitems_from_structure(fmt, t)
1950
1951 nderr = False
1952 try:
1953 x = ndarray_from_structure(items, fmt, t)
1954 except Exception as e:
1955 nderr = e.__class__
1956 self.assertTrue(nderr)
1957
1958 if numpy_array:
1959 numpy_err = False
1960 try:
1961 y = numpy_array_from_structure(items, fmt, t)
1962 except Exception as e:
1963 numpy_err = e.__class__
1964
1965 if 0: # https://github.com/numpy/numpy/issues/2503
1966 self.assertTrue(numpy_err)
1967
1968 def test_ndarray_random_slice_assign(self):
1969 # valid slice assignments

Callers

nothing calls this directly

Calls 7

rand_structureFunction · 0.85
verify_structureFunction · 0.85
randitems_from_structureFunction · 0.85
ndarray_from_structureFunction · 0.85
assertFalseMethod · 0.80
assertTrueMethod · 0.80

Tested by

no test coverage detected