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

Method test_repr_string

testing/python/approx.py:338–355  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

336 )
337
338 def test_repr_string(self):
339 assert repr(approx(1.0)) == "1.0 ± 1.0e-06"
340 assert repr(approx([1.0, 2.0])) == "approx([1.0 ± 1.0e-06, 2.0 ± 2.0e-06])"
341 assert repr(approx((1.0, 2.0))) == "approx((1.0 ± 1.0e-06, 2.0 ± 2.0e-06))"
342 assert repr(approx(inf)) == "inf"
343 assert repr(approx(1.0, rel=nan)) == "1.0 ± ???"
344 assert repr(approx(1.0, rel=inf)) == "1.0 ± inf"
345
346 # Dictionaries aren't ordered, so we need to check both orders.
347 assert repr(approx({"a": 1.0, "b": 2.0})) in (
348 "approx({'a': 1.0 ± 1.0e-06, 'b': 2.0 ± 2.0e-06})",
349 "approx({'b': 2.0 ± 2.0e-06, 'a': 1.0 ± 1.0e-06})",
350 )
351
352 assert repr(approx(42, abs=1)) == "42 ± 1"
353 assert repr(approx(5, rel=0.01)) == "5 ± 0.05"
354 assert repr(approx(24000, abs=500)) == "24000 ± 500"
355 assert repr(approx(1500, abs=555)) == "1500 ± 555"
356
357 def test_repr_complex_numbers(self):
358 assert repr(approx(inf + 1j)) == "(inf+1j)"

Callers

nothing calls this directly

Calls 1

approxFunction · 0.90

Tested by

no test coverage detected