summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_zipfile.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 4a8c1af..f57da5f 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -597,22 +597,19 @@ class PyZipFileTests(unittest.TestCase):
with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
- stdout = sys.stdout
-
# first make sure that the test folder gives error messages
- sys.stdout = reportSIO = io.StringIO()
- zipfp.writepy(packagedir)
+ # (on the badsyntax_... files)
+ with captured_stdout() as reportSIO:
+ zipfp.writepy(packagedir)
reportStr = reportSIO.getvalue()
self.assertTrue('SyntaxError' in reportStr)
# then check that the filter works
- sys.stdout = reportSIO = io.StringIO()
- zipfp.writepy(packagedir, filterfunc=lambda whatever:False)
+ with captured_stdout() as reportSIO:
+ zipfp.writepy(packagedir, filterfunc=lambda whatever: False)
reportStr = reportSIO.getvalue()
self.assertTrue('SyntaxError' not in reportStr)
- sys.stdout = stdout
-
def test_write_with_optimization(self):
import email
packagedir = os.path.dirname(email.__file__)