(self)
| 42 | class DisplayHookTest(unittest.TestCase): |
| 43 | |
| 44 | def test_original_displayhook(self): |
| 45 | dh = sys.__displayhook__ |
| 46 | |
| 47 | with support.captured_stdout() as out: |
| 48 | dh(42) |
| 49 | |
| 50 | self.assertEqual(out.getvalue(), "42\n") |
| 51 | self.assertEqual(builtins._, 42) |
| 52 | |
| 53 | del builtins._ |
| 54 | |
| 55 | with support.captured_stdout() as out: |
| 56 | dh(None) |
| 57 | |
| 58 | self.assertEqual(out.getvalue(), "") |
| 59 | self.assertNotHasAttr(builtins, "_") |
| 60 | |
| 61 | # sys.displayhook() requires arguments |
| 62 | self.assertRaises(TypeError, dh) |
| 63 | |
| 64 | stdout = sys.stdout |
| 65 | try: |
| 66 | del sys.stdout |
| 67 | self.assertRaises(RuntimeError, dh, 42) |
| 68 | finally: |
| 69 | sys.stdout = stdout |
| 70 | |
| 71 | def test_lost_displayhook(self): |
| 72 | displayhook = sys.displayhook |
nothing calls this directly
no test coverage detected