MCPcopy
hub / github.com/pytest-dev/pytest / test_number_re

Method test_number_re

testing/test_doctest.py:1034–1062  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1032 reprec.assertoutcome(failed=1)
1033
1034 def test_number_re(self) -> None:
1035 _number_re = _get_checker()._number_re # type: ignore
1036 for s in [
1037 "1.",
1038 "+1.",
1039 "-1.",
1040 ".1",
1041 "+.1",
1042 "-.1",
1043 "0.1",
1044 "+0.1",
1045 "-0.1",
1046 "1e5",
1047 "+1e5",
1048 "1e+5",
1049 "+1e+5",
1050 "1e-5",
1051 "+1e-5",
1052 "-1e-5",
1053 "1.2e3",
1054 "-1.2e-3",
1055 ]:
1056 print(s)
1057 m = _number_re.match(s)
1058 assert m is not None
1059 assert float(m.group()) == pytest.approx(float(s))
1060 for s in ["1", "abc"]:
1061 print(s)
1062 assert _number_re.match(s) is None
1063
1064 @pytest.mark.parametrize("config_mode", ["ini", "comment"])
1065 def test_number_precision(self, pytester, config_mode):

Callers

nothing calls this directly

Calls 3

_get_checkerFunction · 0.90
matchMethod · 0.80
groupMethod · 0.80

Tested by

no test coverage detected