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

Method _check

numpy/core/tests/test_conversion_utils.py:32–60  ·  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

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