MCPcopy Index your code
hub / github.com/python/cpython / test_parse_float

Method test_parse_float

Lib/test/test_tomllib/test_misc.py:40–66  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

38 tomllib.load(txt_f) # type: ignore[arg-type]
39
40 def test_parse_float(self):
41 doc = """
42 val=0.1
43 biggest1=inf
44 biggest2=+inf
45 smallest=-inf
46 notnum1=nan
47 notnum2=-nan
48 notnum3=+nan
49 """
50 obj = tomllib.loads(doc, parse_float=D)
51 expected = {
52 "val": D("0.1"),
53 "biggest1": D("inf"),
54 "biggest2": D("inf"),
55 "smallest": D("-inf"),
56 "notnum1": D("nan"),
57 "notnum2": D("-nan"),
58 "notnum3": D("nan"),
59 }
60 for k, expected_val in expected.items():
61 actual_val = obj[k]
62 self.assertIsInstance(actual_val, D)
63 if actual_val.is_nan():
64 self.assertTrue(expected_val.is_nan())
65 else:
66 self.assertEqual(actual_val, expected_val)
67
68 def test_deepcopy(self):
69 doc = """

Callers

nothing calls this directly

Calls 7

DClass · 0.90
assertIsInstanceMethod · 0.80
assertTrueMethod · 0.80
loadsMethod · 0.45
itemsMethod · 0.45
is_nanMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected