MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_number_re

Method test_number_re

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

Source from the content-addressed store, hash-verified

939 reprec.assertoutcome(failed=1)
940
941 def test_number_re(self) -> None:
942 _number_re = _get_checker()._number_re # type: ignore
943 for s in [
944 "1.",
945 "+1.",
946 "-1.",
947 ".1",
948 "+.1",
949 "-.1",
950 "0.1",
951 "+0.1",
952 "-0.1",
953 "1e5",
954 "+1e5",
955 "1e+5",
956 "+1e+5",
957 "1e-5",
958 "+1e-5",
959 "-1e-5",
960 "1.2e3",
961 "-1.2e-3",
962 ]:
963 print(s)
964 m = _number_re.match(s)
965 assert m is not None
966 assert float(m.group()) == pytest.approx(float(s))
967 for s in ["1", "abc"]:
968 print(s)
969 assert _number_re.match(s) is None
970
971 @pytest.mark.parametrize("config_mode", ["ini", "comment"])
972 def test_number_precision(self, pytester, config_mode):

Callers

nothing calls this directly

Calls 2

_get_checkerFunction · 0.90
matchMethod · 0.80

Tested by

no test coverage detected