From: Serhiy Storchaka Date: Mon, 20 Jan 2014 19:59:33 +0000 (+0200) Subject: Issue #20262: Warnings are raised now when duplicate names are added in the X-Git-Tag: v3.4.0b3~83 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c46d1faa4a4b483f2b241bfbe932824d54f2f026;p=thirdparty%2FPython%2Fcpython.git Issue #20262: Warnings are raised now when duplicate names are added in the ZIP file or too long ZIP file comment is truncated. --- c46d1faa4a4b483f2b241bfbe932824d54f2f026 diff --cc Lib/test/test_zipfile.py index 33602cff55c4,12a0f71f5d43..1bef5750a152 --- a/Lib/test/test_zipfile.py +++ b/Lib/test/test_zipfile.py @@@ -626,34 -622,6 +626,34 @@@ class PyZipFileTests(unittest.TestCase) self.assertCompiledIn('email/__init__.py', names) self.assertCompiledIn('email/mime/text.py', names) + def test_write_filtered_python_package(self): + import test + packagedir = os.path.dirname(test.__file__) + + with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp: + + # first make sure that the test folder gives error messages + # (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 on the whole package + with captured_stdout() as reportSIO: + zipfp.writepy(packagedir, filterfunc=lambda whatever: False) + reportStr = reportSIO.getvalue() + self.assertTrue('SyntaxError' not in reportStr) + + # then check that the filter works on individual files - with captured_stdout() as reportSIO: ++ with captured_stdout() as reportSIO, self.assertWarns(UserWarning): + zipfp.writepy(packagedir, filterfunc=lambda fn: + 'bad' not in fn) + reportStr = reportSIO.getvalue() + if reportStr: + print(reportStr) + self.assertTrue('SyntaxError' not in reportStr) + def test_write_with_optimization(self): import email packagedir = os.path.dirname(email.__file__) diff --cc Misc/NEWS index 19e2a6e9f1f4,62ffaa508a3b..66d65f084f7b --- a/Misc/NEWS +++ b/Misc/NEWS @@@ -25,9 -25,27 +25,12 @@@ Core and Builtin Library ------- + - Issue #20262: Warnings are raised now when duplicate names are added in the + ZIP file or too long ZIP file comment is truncated. + +- Issue #20165: The unittest module no longer considers tests marked with + @expectedFailure successful if they pass. + - Issue #18574: Added missing newline in 100-Continue reply from http.server.BaseHTTPRequestHandler. Patch by Nikolaus Rath.