mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#19274: use captured_stdout() in the test suite; add NEWS entry.
This commit is contained in:
parent
b0c84cdaac
commit
a606542e95
3 changed files with 15 additions and 12 deletions
|
@ -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__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue