File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -1970,11 +1970,10 @@ def test_close_erroneous_file(self):
19701970 with open (TESTFN , "w" , encoding = "utf-8" ) as fp :
19711971 fp .write ("this is not a legal zip file\n " )
19721972 try :
1973- zf = zipfile .ZipFile (TESTFN )
1973+ with zipfile .ZipFile (TESTFN ) as zf :
1974+ pass
19741975 except zipfile .BadZipFile :
19751976 pass
1976- finally :
1977- zf .close ()
19781977
19791978 def test_is_zip_erroneous_file (self ):
19801979 """Check that is_zipfile() correctly identifies non-zip files."""
@@ -2255,11 +2254,10 @@ def test_empty_zipfile(self):
22552254 zipf = zipfile .ZipFile (TESTFN , mode = "w" )
22562255 zipf .close ()
22572256 try :
2258- zipf = zipfile .ZipFile (TESTFN , mode = "r" )
2257+ with zipfile .ZipFile (TESTFN , mode = "r" ) as zipf :
2258+ pass
22592259 except zipfile .BadZipFile :
22602260 self .fail ("Unable to create empty ZIP file in 'w' mode" )
2261- finally :
2262- zipf .close ()
22632261
22642262 zipf = zipfile .ZipFile (TESTFN , mode = "a" )
22652263 zipf .close ()
You can’t perform that action at this time.
0 commit comments