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