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

Method test_integer

Lib/test/test_pprint.py:489–499  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

487 '2']]]]]""")
488
489 def test_integer(self):
490 self.assertEqual(pprint.pformat(1234567), '1234567')
491 self.assertEqual(pprint.pformat(1234567, underscore_numbers=True), '1_234_567')
492
493 class Temperature(int):
494 def __new__(cls, celsius_degrees):
495 return super().__new__(Temperature, celsius_degrees)
496 def __repr__(self):
497 kelvin_degrees = self + 273.15
498 return f"{kelvin_degrees:.2f}°K"
499 self.assertEqual(pprint.pformat(Temperature(1000)), '1273.15°K')
500
501 def test_sorted_dict(self):
502 # Starting in Python 2.5, pprint sorts dict displays by key regardless

Callers

nothing calls this directly

Calls 3

TemperatureClass · 0.85
pformatMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected