bpo-37376: pprint support for SimpleNamespace by carlbordum · Pull Request #14318 · python/cpython
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, code is almost always more readable when limited to one action per line. Among other things, it makes it much easier to understand what's happening (especially when parentheses are involved).
| self.assertEqual(pprint.pformat(types.SimpleNamespace()), "namespace()") | |
| formatted = pprint.pformat( | |
| types.SimpleNamespace()) | |
| self.assertEqual(formatted, "namespace()") |
Personally I like to separate the 3 parts (setup, actual-thing-to-test, assertions) with blank lines, for further readability, but that's more personal preference:
| self.assertEqual(pprint.pformat(types.SimpleNamespace()), "namespace()") | |
| ns = types.SimpleNamespace() | |
| formatted = pprint.pformat(ns) | |
| self.assertEqual(formatted, "namespace()") |