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
975077a8
Kaydet (Commit)
975077a8
authored
May 19, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor a few tests to use the new requires_zlib decorator.
üst
cad648cb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
79 deletions
+49
-79
test_command_bdist_dumb.py
Lib/packaging/tests/test_command_bdist_dumb.py
+2
-8
test_shutil.py
Lib/test/test_shutil.py
+7
-12
test_zipfile.py
Lib/test/test_zipfile.py
+32
-39
test_zipfile64.py
Lib/test/test_zipfile64.py
+7
-13
test_zipimport.py
Lib/test/test_zipimport.py
+1
-7
No files found.
Lib/packaging/tests/test_command_bdist_dumb.py
Dosyayı görüntüle @
975077a8
...
@@ -3,16 +3,10 @@
...
@@ -3,16 +3,10 @@
import
sys
import
sys
import
os
import
os
# zlib is not used here, but if it's not available
# test_simple_built will fail
try
:
import
zlib
except
ImportError
:
zlib
=
None
from
packaging.dist
import
Distribution
from
packaging.dist
import
Distribution
from
packaging.command.bdist_dumb
import
bdist_dumb
from
packaging.command.bdist_dumb
import
bdist_dumb
from
packaging.tests
import
unittest
,
support
from
packaging.tests
import
unittest
,
support
from
packaging.tests.support
import
requires_zlib
SETUP_PY
=
"""
\
SETUP_PY
=
"""
\
...
@@ -39,7 +33,7 @@ class BuildDumbTestCase(support.TempdirManager,
...
@@ -39,7 +33,7 @@ class BuildDumbTestCase(support.TempdirManager,
sys
.
argv
[:]
=
self
.
old_sys_argv
[
1
]
sys
.
argv
[:]
=
self
.
old_sys_argv
[
1
]
super
(
BuildDumbTestCase
,
self
)
.
tearDown
()
super
(
BuildDumbTestCase
,
self
)
.
tearDown
()
@
unittest.skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_simple_built
(
self
):
def
test_simple_built
(
self
):
# let's create a simple package
# let's create a simple package
...
...
Lib/test/test_shutil.py
Dosyayı görüntüle @
975077a8
...
@@ -21,7 +21,7 @@ import tarfile
...
@@ -21,7 +21,7 @@ import tarfile
import
warnings
import
warnings
from
test
import
support
from
test
import
support
from
test.support
import
TESTFN
,
check_warnings
,
captured_stdout
from
test.support
import
TESTFN
,
check_warnings
,
captured_stdout
,
requires_zlib
try
:
try
:
import
bz2
import
bz2
...
@@ -38,11 +38,6 @@ try:
...
@@ -38,11 +38,6 @@ try:
except
ImportError
:
except
ImportError
:
UID_GID_SUPPORT
=
False
UID_GID_SUPPORT
=
False
try
:
import
zlib
except
ImportError
:
zlib
=
None
try
:
try
:
import
zipfile
import
zipfile
ZIP_SUPPORT
=
True
ZIP_SUPPORT
=
True
...
@@ -444,7 +439,7 @@ class TestShutil(unittest.TestCase):
...
@@ -444,7 +439,7 @@ class TestShutil(unittest.TestCase):
self
.
assertEqual
(
getattr
(
file1_stat
,
'st_flags'
),
self
.
assertEqual
(
getattr
(
file1_stat
,
'st_flags'
),
getattr
(
file2_stat
,
'st_flags'
))
getattr
(
file2_stat
,
'st_flags'
))
@
unittest.skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_make_tarball
(
self
):
def
test_make_tarball
(
self
):
# creating something to tar
# creating something to tar
tmpdir
=
self
.
mkdtemp
()
tmpdir
=
self
.
mkdtemp
()
...
@@ -507,7 +502,7 @@ class TestShutil(unittest.TestCase):
...
@@ -507,7 +502,7 @@ class TestShutil(unittest.TestCase):
base_name
=
os
.
path
.
join
(
tmpdir2
,
'archive'
)
base_name
=
os
.
path
.
join
(
tmpdir2
,
'archive'
)
return
tmpdir
,
tmpdir2
,
base_name
return
tmpdir
,
tmpdir2
,
base_name
@
unittest.skipUnless
(
zlib
,
"Requires zlib"
)
@
requires_zlib
@unittest.skipUnless
(
find_executable
(
'tar'
)
and
find_executable
(
'gzip'
),
@unittest.skipUnless
(
find_executable
(
'tar'
)
and
find_executable
(
'gzip'
),
'Need the tar command to run'
)
'Need the tar command to run'
)
def
test_tarfile_vs_tar
(
self
):
def
test_tarfile_vs_tar
(
self
):
...
@@ -562,7 +557,7 @@ class TestShutil(unittest.TestCase):
...
@@ -562,7 +557,7 @@ class TestShutil(unittest.TestCase):
tarball
=
base_name
+
'.tar'
tarball
=
base_name
+
'.tar'
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
self
.
assertTrue
(
os
.
path
.
exists
(
tarball
))
@
unittest.skipUnless
(
zlib
,
"Requires zlib"
)
@
requires_zlib
@unittest.skipUnless
(
ZIP_SUPPORT
,
'Need zip support to run'
)
@unittest.skipUnless
(
ZIP_SUPPORT
,
'Need zip support to run'
)
def
test_make_zipfile
(
self
):
def
test_make_zipfile
(
self
):
# creating something to tar
# creating something to tar
...
@@ -586,7 +581,7 @@ class TestShutil(unittest.TestCase):
...
@@ -586,7 +581,7 @@ class TestShutil(unittest.TestCase):
base_name
=
os
.
path
.
join
(
tmpdir
,
'archive'
)
base_name
=
os
.
path
.
join
(
tmpdir
,
'archive'
)
self
.
assertRaises
(
ValueError
,
make_archive
,
base_name
,
'xxx'
)
self
.
assertRaises
(
ValueError
,
make_archive
,
base_name
,
'xxx'
)
@
unittest.skipUnless
(
zlib
,
"Requires zlib"
)
@
requires_zlib
def
test_make_archive_owner_group
(
self
):
def
test_make_archive_owner_group
(
self
):
# testing make_archive with owner and group, with various combinations
# testing make_archive with owner and group, with various combinations
# this works even if there's not gid/uid support
# this works even if there's not gid/uid support
...
@@ -614,7 +609,7 @@ class TestShutil(unittest.TestCase):
...
@@ -614,7 +609,7 @@ class TestShutil(unittest.TestCase):
self
.
assertTrue
(
os
.
path
.
exists
(
res
))
self
.
assertTrue
(
os
.
path
.
exists
(
res
))
@
unittest.skipUnless
(
zlib
,
"Requires zlib"
)
@
requires_zlib
@unittest.skipUnless
(
UID_GID_SUPPORT
,
"Requires grp and pwd support"
)
@unittest.skipUnless
(
UID_GID_SUPPORT
,
"Requires grp and pwd support"
)
def
test_tarfile_root_owner
(
self
):
def
test_tarfile_root_owner
(
self
):
tmpdir
,
tmpdir2
,
base_name
=
self
.
_create_files
()
tmpdir
,
tmpdir2
,
base_name
=
self
.
_create_files
()
...
@@ -683,7 +678,7 @@ class TestShutil(unittest.TestCase):
...
@@ -683,7 +678,7 @@ class TestShutil(unittest.TestCase):
diff
.
append
(
file_
)
diff
.
append
(
file_
)
return
diff
return
diff
@
unittest.skipUnless
(
zlib
,
"Requires zlib"
)
@
requires_zlib
def
test_unpack_archive
(
self
):
def
test_unpack_archive
(
self
):
formats
=
[
'tar'
,
'gztar'
,
'zip'
]
formats
=
[
'tar'
,
'gztar'
,
'zip'
]
if
BZ2_SUPPORTED
:
if
BZ2_SUPPORTED
:
...
...
Lib/test/test_zipfile.py
Dosyayı görüntüle @
975077a8
# We can test part of the module without zlib.
try
:
import
zlib
except
ImportError
:
zlib
=
None
import
io
import
io
import
os
import
os
import
sys
import
sys
...
@@ -19,7 +13,7 @@ from tempfile import TemporaryFile
...
@@ -19,7 +13,7 @@ from tempfile import TemporaryFile
from
random
import
randint
,
random
from
random
import
randint
,
random
from
unittest
import
skipUnless
from
unittest
import
skipUnless
from
test.support
import
TESTFN
,
run_unittest
,
findfile
,
unlink
from
test.support
import
TESTFN
,
run_unittest
,
findfile
,
unlink
,
requires_zlib
TESTFN2
=
TESTFN
+
"2"
TESTFN2
=
TESTFN
+
"2"
TESTFNDIR
=
TESTFN
+
"d"
TESTFNDIR
=
TESTFN
+
"d"
...
@@ -269,44 +263,44 @@ class TestsWithSourceFile(unittest.TestCase):
...
@@ -269,44 +263,44 @@ class TestsWithSourceFile(unittest.TestCase):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_iterlines_test
(
f
,
zipfile
.
ZIP_STORED
)
self
.
zip_iterlines_test
(
f
,
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_deflated
(
self
):
def
test_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_open_deflated
(
self
):
def
test_open_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_random_open_deflated
(
self
):
def
test_random_open_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_random_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_random_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_readline_read_deflated
(
self
):
def
test_readline_read_deflated
(
self
):
# Issue #7610: calls to readline() interleaved with calls to read().
# Issue #7610: calls to readline() interleaved with calls to read().
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_readline_read_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_readline_read_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_readline_deflated
(
self
):
def
test_readline_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_readline_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_readline_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_readlines_deflated
(
self
):
def
test_readlines_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_readlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_readlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_iterlines_deflated
(
self
):
def
test_iterlines_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_iterlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_iterlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_low_compression
(
self
):
def
test_low_compression
(
self
):
"""Check for cases where compressed data is larger than original."""
"""Check for cases where compressed data is larger than original."""
# Create the ZIP archive
# Create the ZIP archive
...
@@ -359,7 +353,7 @@ class TestsWithSourceFile(unittest.TestCase):
...
@@ -359,7 +353,7 @@ class TestsWithSourceFile(unittest.TestCase):
with
open
(
TESTFN
,
"rb"
)
as
f
:
with
open
(
TESTFN
,
"rb"
)
as
f
:
self
.
assertEqual
(
zipfp
.
read
(
TESTFN
),
f
.
read
())
self
.
assertEqual
(
zipfp
.
read
(
TESTFN
),
f
.
read
())
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_per_file_compression
(
self
):
def
test_per_file_compression
(
self
):
"""Check that files within a Zip archive can have different
"""Check that files within a Zip archive can have different
compression options."""
compression options."""
...
@@ -428,19 +422,18 @@ class TestsWithSourceFile(unittest.TestCase):
...
@@ -428,19 +422,18 @@ class TestsWithSourceFile(unittest.TestCase):
# remove the test file subdirectories
# remove the test file subdirectories
shutil
.
rmtree
(
os
.
path
.
join
(
os
.
getcwd
(),
'ziptest2dir'
))
shutil
.
rmtree
(
os
.
path
.
join
(
os
.
getcwd
(),
'ziptest2dir'
))
def
test_writestr_compression
(
self
):
def
test_writestr_compression
_stored
(
self
):
zipfp
=
zipfile
.
ZipFile
(
TESTFN2
,
"w"
)
zipfp
=
zipfile
.
ZipFile
(
TESTFN2
,
"w"
)
zipfp
.
writestr
(
"a.txt"
,
"hello world"
,
compress_type
=
zipfile
.
ZIP_STORED
)
zipfp
.
writestr
(
"a.txt"
,
"hello world"
,
compress_type
=
zipfile
.
ZIP_STORED
)
if
zlib
:
zipfp
.
writestr
(
"b.txt"
,
"hello world"
,
compress_type
=
zipfile
.
ZIP_DEFLATED
)
info
=
zipfp
.
getinfo
(
'a.txt'
)
info
=
zipfp
.
getinfo
(
'a.txt'
)
self
.
assertEqual
(
info
.
compress_type
,
zipfile
.
ZIP_STORED
)
self
.
assertEqual
(
info
.
compress_type
,
zipfile
.
ZIP_STORED
)
if
zlib
:
@requires_zlib
info
=
zipfp
.
getinfo
(
'b.txt'
)
def
test_writestr_compression_deflated
(
self
):
self
.
assertEqual
(
info
.
compress_type
,
zipfile
.
ZIP_DEFLATED
)
zipfp
=
zipfile
.
ZipFile
(
TESTFN2
,
"w"
)
zipfp
.
writestr
(
"b.txt"
,
"hello world"
,
compress_type
=
zipfile
.
ZIP_DEFLATED
)
info
=
zipfp
.
getinfo
(
'b.txt'
)
self
.
assertEqual
(
info
.
compress_type
,
zipfile
.
ZIP_DEFLATED
)
def
zip_test_writestr_permissions
(
self
,
f
,
compression
):
def
zip_test_writestr_permissions
(
self
,
f
,
compression
):
# Make sure that writestr creates files with mode 0600,
# Make sure that writestr creates files with mode 0600,
...
@@ -489,7 +482,7 @@ class TestsWithSourceFile(unittest.TestCase):
...
@@ -489,7 +482,7 @@ class TestsWithSourceFile(unittest.TestCase):
except
zipfile
.
BadZipFile
:
except
zipfile
.
BadZipFile
:
self
.
assertTrue
(
zipfp2
.
fp
is
None
,
'zipfp is not closed'
)
self
.
assertTrue
(
zipfp2
.
fp
is
None
,
'zipfp is not closed'
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_unicode_filenames
(
self
):
def
test_unicode_filenames
(
self
):
# bug #10801
# bug #10801
fname
=
findfile
(
'zip_cp437_header.zip'
)
fname
=
findfile
(
'zip_cp437_header.zip'
)
...
@@ -598,7 +591,7 @@ class TestZip64InSmallFiles(unittest.TestCase):
...
@@ -598,7 +591,7 @@ class TestZip64InSmallFiles(unittest.TestCase):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_test
(
f
,
zipfile
.
ZIP_STORED
)
self
.
zip_test
(
f
,
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_deflated
(
self
):
def
test_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
...
@@ -958,7 +951,7 @@ class OtherTests(unittest.TestCase):
...
@@ -958,7 +951,7 @@ class OtherTests(unittest.TestCase):
def
test_testzip_with_bad_crc_stored
(
self
):
def
test_testzip_with_bad_crc_stored
(
self
):
self
.
check_testzip_with_bad_crc
(
zipfile
.
ZIP_STORED
)
self
.
check_testzip_with_bad_crc
(
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_testzip_with_bad_crc_deflated
(
self
):
def
test_testzip_with_bad_crc_deflated
(
self
):
self
.
check_testzip_with_bad_crc
(
zipfile
.
ZIP_DEFLATED
)
self
.
check_testzip_with_bad_crc
(
zipfile
.
ZIP_DEFLATED
)
...
@@ -986,7 +979,7 @@ class OtherTests(unittest.TestCase):
...
@@ -986,7 +979,7 @@ class OtherTests(unittest.TestCase):
def
test_read_with_bad_crc_stored
(
self
):
def
test_read_with_bad_crc_stored
(
self
):
self
.
check_read_with_bad_crc
(
zipfile
.
ZIP_STORED
)
self
.
check_read_with_bad_crc
(
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_read_with_bad_crc_deflated
(
self
):
def
test_read_with_bad_crc_deflated
(
self
):
self
.
check_read_with_bad_crc
(
zipfile
.
ZIP_DEFLATED
)
self
.
check_read_with_bad_crc
(
zipfile
.
ZIP_DEFLATED
)
...
@@ -1006,7 +999,7 @@ class OtherTests(unittest.TestCase):
...
@@ -1006,7 +999,7 @@ class OtherTests(unittest.TestCase):
def
test_read_return_size_stored
(
self
):
def
test_read_return_size_stored
(
self
):
self
.
check_read_return_size
(
zipfile
.
ZIP_STORED
)
self
.
check_read_return_size
(
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_read_return_size_deflated
(
self
):
def
test_read_return_size_deflated
(
self
):
self
.
check_read_return_size
(
zipfile
.
ZIP_DEFLATED
)
self
.
check_read_return_size
(
zipfile
.
ZIP_DEFLATED
)
...
@@ -1092,7 +1085,7 @@ class DecryptionTests(unittest.TestCase):
...
@@ -1092,7 +1085,7 @@ class DecryptionTests(unittest.TestCase):
self
.
zip2
.
setpassword
(
b
"perl"
)
self
.
zip2
.
setpassword
(
b
"perl"
)
self
.
assertRaises
(
RuntimeError
,
self
.
zip2
.
read
,
"zero"
)
self
.
assertRaises
(
RuntimeError
,
self
.
zip2
.
read
,
"zero"
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_good_password
(
self
):
def
test_good_password
(
self
):
self
.
zip
.
setpassword
(
b
"python"
)
self
.
zip
.
setpassword
(
b
"python"
)
self
.
assertEqual
(
self
.
zip
.
read
(
"test.txt"
),
self
.
plain
)
self
.
assertEqual
(
self
.
zip
.
read
(
"test.txt"
),
self
.
plain
)
...
@@ -1142,7 +1135,7 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
...
@@ -1142,7 +1135,7 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_test
(
f
,
zipfile
.
ZIP_STORED
)
self
.
zip_test
(
f
,
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_deflated
(
self
):
def
test_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
...
@@ -1182,7 +1175,7 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
...
@@ -1182,7 +1175,7 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_open_test
(
f
,
zipfile
.
ZIP_STORED
)
self
.
zip_open_test
(
f
,
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_open_deflated
(
self
):
def
test_open_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
...
@@ -1210,13 +1203,13 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
...
@@ -1210,13 +1203,13 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_random_open_test
(
f
,
zipfile
.
ZIP_STORED
)
self
.
zip_random_open_test
(
f
,
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_random_open_deflated
(
self
):
def
test_random_open_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
zip_random_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zip_random_open_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
class
TestsWithMultipleOpens
(
unittest
.
TestCase
):
class
TestsWithMultipleOpens
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
# Create the ZIP archive
# Create the ZIP archive
...
@@ -1408,28 +1401,28 @@ class UniversalNewlineTests(unittest.TestCase):
...
@@ -1408,28 +1401,28 @@ class UniversalNewlineTests(unittest.TestCase):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
iterlines_test
(
f
,
zipfile
.
ZIP_STORED
)
self
.
iterlines_test
(
f
,
zipfile
.
ZIP_STORED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_read_deflated
(
self
):
def
test_read_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
read_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
read_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_readline_read_deflated
(
self
):
def
test_readline_read_deflated
(
self
):
# Issue #7610: calls to readline() interleaved with calls to read().
# Issue #7610: calls to readline() interleaved with calls to read().
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
readline_read_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
readline_read_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_readline_deflated
(
self
):
def
test_readline_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
readline_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
readline_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_readlines_deflated
(
self
):
def
test_readlines_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
readlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
readlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
@
skipUnless
(
zlib
,
"requires zlib"
)
@
requires_zlib
def
test_iterlines_deflated
(
self
):
def
test_iterlines_deflated
(
self
):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
for
f
in
(
TESTFN2
,
TemporaryFile
(),
io
.
BytesIO
()):
self
.
iterlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
iterlines_test
(
f
,
zipfile
.
ZIP_DEFLATED
)
...
...
Lib/test/test_zipfile64.py
Dosyayı görüntüle @
975077a8
...
@@ -11,12 +11,6 @@ support.requires(
...
@@ -11,12 +11,6 @@ support.requires(
'test requires loads of disk-space bytes and a long time to run'
'test requires loads of disk-space bytes and a long time to run'
)
)
# We can test part of the module without zlib.
try
:
import
zlib
except
ImportError
:
zlib
=
None
import
zipfile
,
os
,
unittest
import
zipfile
,
os
,
unittest
import
time
import
time
import
sys
import
sys
...
@@ -24,7 +18,7 @@ import sys
...
@@ -24,7 +18,7 @@ import sys
from
io
import
StringIO
from
io
import
StringIO
from
tempfile
import
TemporaryFile
from
tempfile
import
TemporaryFile
from
test.support
import
TESTFN
,
run_unittest
from
test.support
import
TESTFN
,
run_unittest
,
requires_zlib
TESTFN2
=
TESTFN
+
"2"
TESTFN2
=
TESTFN
+
"2"
...
@@ -81,12 +75,12 @@ class TestsWithSourceFile(unittest.TestCase):
...
@@ -81,12 +75,12 @@ class TestsWithSourceFile(unittest.TestCase):
for
f
in
TemporaryFile
(),
TESTFN2
:
for
f
in
TemporaryFile
(),
TESTFN2
:
self
.
zipTest
(
f
,
zipfile
.
ZIP_STORED
)
self
.
zipTest
(
f
,
zipfile
.
ZIP_STORED
)
if
zlib
:
@requires_zlib
def
testDeflated
(
self
):
def
testDeflated
(
self
):
# Try the temp file first. If we do TESTFN2 first, then it hogs
# Try the temp file first. If we do TESTFN2 first, then it hogs
# gigabytes of disk space for the duration of the test.
# gigabytes of disk space for the duration of the test.
for
f
in
TemporaryFile
(),
TESTFN2
:
for
f
in
TemporaryFile
(),
TESTFN2
:
self
.
zipTest
(
f
,
zipfile
.
ZIP_DEFLATED
)
self
.
zipTest
(
f
,
zipfile
.
ZIP_DEFLATED
)
def
tearDown
(
self
):
def
tearDown
(
self
):
for
fname
in
TESTFN
,
TESTFN2
:
for
fname
in
TESTFN
,
TESTFN2
:
...
...
Lib/test/test_zipimport.py
Dosyayı görüntüle @
975077a8
...
@@ -9,12 +9,6 @@ import unittest
...
@@ -9,12 +9,6 @@ import unittest
from
test
import
support
from
test
import
support
from
test.test_importhooks
import
ImportHooksBaseTestCase
,
test_src
,
test_co
from
test.test_importhooks
import
ImportHooksBaseTestCase
,
test_src
,
test_co
# some tests can be ran even without zlib
try
:
import
zlib
except
ImportError
:
zlib
=
None
from
zipfile
import
ZipFile
,
ZipInfo
,
ZIP_STORED
,
ZIP_DEFLATED
from
zipfile
import
ZipFile
,
ZipInfo
,
ZIP_STORED
,
ZIP_DEFLATED
import
zipimport
import
zipimport
...
@@ -397,7 +391,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
...
@@ -397,7 +391,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
os
.
remove
(
filename
)
os
.
remove
(
filename
)
@
unittest.skipUnless
(
zlib
,
"requires zlib"
)
@
support.requires_zlib
class
CompressedZipImportTestCase
(
UncompressedZipImportTestCase
):
class
CompressedZipImportTestCase
(
UncompressedZipImportTestCase
):
compression
=
ZIP_DEFLATED
compression
=
ZIP_DEFLATED
...
...
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