MCPcopy Index your code
hub / github.com/numpy/numpy / _check

Method _check

numpy/_core/tests/test_conversion_utils.py:31–59  ·  view source on GitHub ↗

Takes valid non-deprecated inputs for converters, runs converters on inputs, checks correctness of outputs, warnings and errors

(self, val, expected)

Source from the content-addressed store, hash-verified

29 assert self.conv(val) == expected
30
31 def _check(self, val, expected):
32 """Takes valid non-deprecated inputs for converters,
33 runs converters on inputs, checks correctness of outputs,
34 warnings and errors"""
35 assert self.conv(val) == expected
36
37 if self.allow_bytes:
38 assert self.conv(val.encode('ascii')) == expected
39 else:
40 with pytest.raises(TypeError):
41 self.conv(val.encode('ascii'))
42
43 if len(val) != 1:
44 if self.exact_match:
45 self._check_value_error(val[:1])
46 self._check_value_error(val + '\0')
47 else:
48 self._check_conv_assert_warn(val[:1], expected)
49
50 if self.case_insensitive:
51 if val != val.lower():
52 self._check_conv_assert_warn(val.lower(), expected)
53 if val != val.upper():
54 self._check_conv_assert_warn(val.upper(), expected)
55 else:
56 if val != val.lower():
57 self._check_value_error(val.lower())
58 if val != val.upper():
59 self._check_value_error(val.upper())
60
61 def test_wrong_type(self):
62 # common cases which apply to all the below

Callers 7

test_validMethod · 0.45
test_validMethod · 0.45
test_validMethod · 0.45
test_validMethod · 0.45
test_validMethod · 0.45
test_validMethod · 0.45
test_validMethod · 0.45

Calls 5

_check_value_errorMethod · 0.95
encodeMethod · 0.80
lowerMethod · 0.80
upperMethod · 0.80

Tested by

no test coverage detected