diff options
Diffstat (limited to 'Lib/test/test_file.py')
-rw-r--r-- | Lib/test/test_file.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py index b93bdbd..2d791a5 100644 --- a/Lib/test/test_file.py +++ b/Lib/test/test_file.py @@ -531,6 +531,20 @@ class StdoutTests(unittest.TestCase): finally: sys.stdout = save_stdout + def test_del_stdout_before_print(self): + # Issue 4597: 'print' with no argument wasn't reporting when + # sys.stdout was deleted. + save_stdout = sys.stdout + del sys.stdout + try: + print + except RuntimeError as e: + self.assertEquals(str(e), "lost sys.stdout") + else: + self.fail("Expected RuntimeError") + finally: + sys.stdout = save_stdout + def test_main(): # Historically, these tests have been sloppy about removing TESTFN. |