Skip to content

Commit 3796fdf

Browse files
committed
Fix the tests to match the PEP update
1 parent b0c0674 commit 3796fdf

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

Lib/test/test_tarfile.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3804,22 +3804,19 @@ def __exit__(self, *exc_info):
38043804
def test_errorlevel(self):
38053805
def extracterror_filter(tarinfo, path):
38063806
raise tarfile.ExtractError('failed with ExtractError')
3807-
def tarerror_filter(tarinfo, path):
3808-
raise tarfile.ExtractError('failed with base TarError')
38093807
def filtererror_filter(tarinfo, path):
38103808
raise tarfile.FilterError('failed with FilterError')
38113809
def oserror_filter(tarinfo, path):
38123810
raise OSError('failed with OSError')
3811+
def tarerror_filter(tarinfo, path):
3812+
raise tarfile.TarError('failed with base TarError')
38133813
def valueerror_filter(tarinfo, path):
38143814
raise ValueError('failed with ValueError')
38153815

38163816
with ArchiveMaker() as arc:
38173817
arc.add('file')
38183818

3819-
# If errorlevel is 0, errors are ignored when using TarFile.extract().
3820-
3821-
with self.check_context(arc.open(errorlevel=0), tarerror_filter):
3822-
self.expect_file('file')
3819+
# If errorlevel is 0, errors affected by errorlevel are ignored
38233820

38243821
with self.check_context(arc.open(errorlevel=0), extracterror_filter):
38253822
self.expect_file('file')
@@ -3830,14 +3827,14 @@ def valueerror_filter(tarinfo, path):
38303827
with self.check_context(arc.open(errorlevel=0), oserror_filter):
38313828
self.expect_file('file')
38323829

3830+
with self.check_context(arc.open(errorlevel=0), tarerror_filter):
3831+
self.expect_exception(tarfile.TarError)
3832+
38333833
with self.check_context(arc.open(errorlevel=0), valueerror_filter):
38343834
self.expect_exception(ValueError)
38353835

38363836
# If 1, all fatal errors are raised
38373837

3838-
with self.check_context(arc.open(errorlevel=1), tarerror_filter):
3839-
self.expect_file('file')
3840-
38413838
with self.check_context(arc.open(errorlevel=1), extracterror_filter):
38423839
self.expect_file('file')
38433840

@@ -3847,14 +3844,14 @@ def valueerror_filter(tarinfo, path):
38473844
with self.check_context(arc.open(errorlevel=1), oserror_filter):
38483845
self.expect_exception(OSError)
38493846

3847+
with self.check_context(arc.open(errorlevel=1), tarerror_filter):
3848+
self.expect_exception(tarfile.TarError)
3849+
38503850
with self.check_context(arc.open(errorlevel=1), valueerror_filter):
38513851
self.expect_exception(ValueError)
38523852

38533853
# If 2, all non-fatal errors are raised as well.
38543854

3855-
with self.check_context(arc.open(errorlevel=2), tarerror_filter):
3856-
self.expect_exception(tarfile.TarError)
3857-
38583855
with self.check_context(arc.open(errorlevel=2), extracterror_filter):
38593856
self.expect_exception(tarfile.ExtractError)
38603857

@@ -3864,12 +3861,15 @@ def valueerror_filter(tarinfo, path):
38643861
with self.check_context(arc.open(errorlevel=2), oserror_filter):
38653862
self.expect_exception(OSError)
38663863

3864+
with self.check_context(arc.open(errorlevel=2), tarerror_filter):
3865+
self.expect_exception(tarfile.TarError)
3866+
38673867
with self.check_context(arc.open(errorlevel=2), valueerror_filter):
38683868
self.expect_exception(ValueError)
38693869

3870-
# We only handle TarError & OSError specially.
3870+
# We only handle ExtractionError, FilterError & OSError specially.
38713871

3872-
with self.check_context(arc.open(errorlevel='boo!'), tarerror_filter):
3872+
with self.check_context(arc.open(errorlevel='boo!'), filtererror_filter):
38733873
self.expect_exception(TypeError) # errorlevel is not int
38743874

38753875

0 commit comments

Comments
 (0)