(self)
| 384 | self.assertEqual(pprint.pformat(Temperature(1000)), '1273.15°K') |
| 385 | |
| 386 | def test_sorted_dict(self): |
| 387 | # Starting in Python 2.5, pprint sorts dict displays by key regardless |
| 388 | # of how small the dictionary may be. |
| 389 | # Before the change, on 32-bit Windows pformat() gave order |
| 390 | # 'a', 'c', 'b' here, so this test failed. |
| 391 | d = {'a': 1, 'b': 1, 'c': 1} |
| 392 | self.assertEqual(pprint.pformat(d), "{'a': 1, 'b': 1, 'c': 1}") |
| 393 | self.assertEqual(pprint.pformat([d, d]), |
| 394 | "[{'a': 1, 'b': 1, 'c': 1}, {'a': 1, 'b': 1, 'c': 1}]") |
| 395 | |
| 396 | # The next one is kind of goofy. The sorted order depends on the |
| 397 | # alphabetic order of type names: "int" < "str" < "tuple". Before |
| 398 | # Python 2.5, this was in the test_same_as_repr() test. It's worth |
| 399 | # keeping around for now because it's one of few tests of pprint |
| 400 | # against a crazy mix of types. |
| 401 | self.assertEqual(pprint.pformat({"xy\tab\n": (3,), 5: [[]], (): {}}), |
| 402 | r"{5: [[]], 'xy\tab\n': (3,), (): {}}") |
| 403 | |
| 404 | def test_sort_dict(self): |
| 405 | d = dict.fromkeys('cba') |
nothing calls this directly
no test coverage detected