Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2a3d7d1

Browse files
Test the open of non-exitent tarfile in all modes.
1 parent 6cbc5f7 commit 2a3d7d1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

Lib/test/test_tarfile.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,12 @@ def test_empty_tarfile(self):
232232
finally:
233233
tar.close()
234234

235+
def test_non_existent_tarfile(self):
236+
# Test for issue11513: prevent non-existent gzipped tarfiles raising
237+
# multiple exceptions.
238+
with self.assertRaisesRegex(FileNotFoundError, "xxx"):
239+
tarfile.open("xxx", self.mode)
240+
235241
def test_null_tarfile(self):
236242
# Test for issue6123: Allow opening empty archives.
237243
# This test guarantees that tarfile.open() does not treat an empty
@@ -444,11 +450,7 @@ class MiscReadTest(MiscReadTestBase, unittest.TestCase):
444450
test_fail_comp = None
445451

446452
class GzipMiscReadTest(GzipTest, MiscReadTestBase, unittest.TestCase):
447-
def test_non_existent_targz_file(self):
448-
# Test for issue11513: prevent non-existent gzipped tarfiles raising
449-
# multiple exceptions.
450-
with self.assertRaisesRegex(FileNotFoundError, "xxx"):
451-
tarfile.open("xxx", self.mode)
453+
pass
452454

453455
class Bz2MiscReadTest(Bz2Test, MiscReadTestBase, unittest.TestCase):
454456
def test_no_name_argument(self):

0 commit comments

Comments
 (0)