Takes valid non-deprecated inputs for converters, runs converters on inputs, checks correctness of outputs, warnings and errors
(self, val, expected)
| 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 |
no test coverage detected