From dbfed710a151f3f033cd3fc8be4fb9fd9c04a6c7 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 11 Dec 1996 16:54:54 +0000 Subject: [PATCH] Be more careful with the shuffling of stdout. --- Lib/test/autotest.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Lib/test/autotest.py b/Lib/test/autotest.py index 4b15c2639ce..aadd1702ff6 100644 --- a/Lib/test/autotest.py +++ b/Lib/test/autotest.py @@ -89,12 +89,13 @@ def usage(status): def do_one_test(t, outdir): filename = os.path.join(outdir, t) real_stdout = sys.stdout + if generate: + print 'Generating:', filename + fake_stdout = open(filename, 'w') + else: + fake_stdout = Compare(filename) try: - if generate: - print 'Generating:', filename - sys.stdout = open(filename, 'w') - else: - sys.stdout = Compare(filename) + sys.stdout = fake_stdout print t unload(t) try: @@ -104,8 +105,8 @@ def do_one_test(t, outdir): sys.stderr.write(msg+': Un-installed' ' optional module?\n') finally: - sys.stdout.close() sys.stdout = real_stdout + fake_stdout.close()