Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
04a51ec8
Kaydet (Commit)
04a51ec8
authored
Mar 29, 2007
tarafından
Collin Winter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make test_zipfile clean up its temporary files properly.
üst
d28fcbc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
test_zipfile.py
Lib/test/test_zipfile.py
+12
-7
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
04a51ec8
...
...
@@ -10,6 +10,7 @@ from StringIO import StringIO
from
tempfile
import
TemporaryFile
from
random
import
randint
,
random
import
test.test_support
as
support
from
test.test_support
import
TESTFN
,
run_unittest
TESTFN2
=
TESTFN
+
"2"
...
...
@@ -454,8 +455,6 @@ class OtherTests(unittest.TestCase):
self
.
assertEqual
(
zf
.
read
(
filename
),
content
)
zf
.
close
()
os
.
unlink
(
TESTFN
)
def
testCloseErroneousFile
(
self
):
# This test checks that the ZipFile constructor closes the file object
# it opens if there's an error in the file. If it doesn't, the traceback
...
...
@@ -469,7 +468,7 @@ class OtherTests(unittest.TestCase):
try
:
zf
=
zipfile
.
ZipFile
(
TESTFN
)
except
zipfile
.
BadZipfile
:
os
.
unlink
(
TESTFN
)
pass
def
testIsZipErroneousFile
(
self
):
# This test checks that the is_zipfile function correctly identifies
...
...
@@ -478,7 +477,6 @@ class OtherTests(unittest.TestCase):
fp
.
write
(
"this is not a legal zip file
\n
"
)
fp
.
close
()
chk
=
zipfile
.
is_zipfile
(
TESTFN
)
os
.
unlink
(
TESTFN
)
self
.
assert_
(
chk
is
False
)
def
testIsZipValidFile
(
self
):
...
...
@@ -488,7 +486,6 @@ class OtherTests(unittest.TestCase):
zipf
.
writestr
(
"foo.txt"
,
"O, for a Muse of Fire!"
)
zipf
.
close
()
chk
=
zipfile
.
is_zipfile
(
TESTFN
)
os
.
unlink
(
TESTFN
)
self
.
assert_
(
chk
is
True
)
def
testNonExistentFileRaisesIOError
(
self
):
...
...
@@ -517,6 +514,10 @@ class OtherTests(unittest.TestCase):
# version of .testzip would swallow this exception (and any other)
# and report that the first file in the archive was corrupt.
self
.
assertRaises
(
RuntimeError
,
zipf
.
testzip
)
def
tearDown
(
self
):
support
.
unlink
(
TESTFN
)
support
.
unlink
(
TESTFN2
)
class
DecryptionTests
(
unittest
.
TestCase
):
# This test checks that ZIP decryption works. Since the library does not
...
...
@@ -567,6 +568,10 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
fp
=
open
(
TESTFN
,
"wb"
)
fp
.
write
(
self
.
data
)
fp
.
close
()
def
tearDown
(
self
):
support
.
unlink
(
TESTFN
)
support
.
unlink
(
TESTFN2
)
def
makeTestArchive
(
self
,
f
,
compression
):
# Create the ZIP archive
...
...
@@ -799,6 +804,8 @@ class UniversalNewlineTests(unittest.TestCase):
def
tearDown
(
self
):
for
sep
,
fn
in
self
.
arcfiles
.
items
():
os
.
remove
(
fn
)
support
.
unlink
(
TESTFN
)
support
.
unlink
(
TESTFN2
)
def
test_main
():
...
...
@@ -806,7 +813,5 @@ def test_main():
PyZipFileTests
,
DecryptionTests
,
TestsWithMultipleOpens
,
UniversalNewlineTests
,
TestsWithRandomBinaryFiles
)
#run_unittest(TestZip64InSmallFiles)
if
__name__
==
"__main__"
:
test_main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment