[Python-checkins] cpython (2.7): Backported test for the open of non-existent tarfile.

serhiy.storchaka python-checkins at python.org
Mon Jan 13 18:10:41 CET 2014


http://hg.python.org/cpython/rev/4eac22a9ae72
changeset: 88440:4eac22a9ae72
branch: 2.7
parent: 88434:de62e7a64346
user: Serhiy Storchaka <storchaka at gmail.com>
date: Mon Jan 13 19:08:51 2014 +0200
summary:
 Backported test for the open of non-existent tarfile.
files:
 Lib/test/test_tarfile.py | 8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -181,6 +181,14 @@
 self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, self.mode)
 self.assertRaises(tarfile.ReadError, tarfile.open, tmpname)
 
+ def test_non_existent_tarfile(self):
+ # Test for issue11513: prevent non-existent gzipped tarfiles raising
+ # multiple exceptions.
+ exctype = OSError if '|' in self.mode else IOError
+ with self.assertRaisesRegexp(exctype, "xxx") as ex:
+ tarfile.open("xxx", self.mode)
+ self.assertEqual(ex.exception.errno, errno.ENOENT)
+
 def test_ignore_zeros(self):
 # Test TarFile's ignore_zeros option.
 if self.mode.endswith(":gz"):
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /