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
cfc2c7bb
Kaydet (Commit)
cfc2c7bb
authored
Şub 05, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #19920: Added tests for TarFile.list(). Based on patch by Vajrasky Kok.
üst
dd9d64eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
0 deletions
+79
-0
test_tarfile.py
Lib/test/test_tarfile.py
+77
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_tarfile.py
Dosyayı görüntüle @
cfc2c7bb
...
...
@@ -158,6 +158,80 @@ class UstarReadTest(ReadTest):
self
.
_test_fileobj_link
(
"symtype2"
,
"ustar/regtype"
)
class
ListTest
(
ReadTest
,
unittest
.
TestCase
):
# Override setUp to use default encoding (UTF-8)
def
setUp
(
self
):
self
.
tar
=
tarfile
.
open
(
self
.
tarname
,
mode
=
self
.
mode
)
def
test_list
(
self
):
with
test_support
.
captured_stdout
()
as
t
:
self
.
tar
.
list
(
verbose
=
False
)
out
=
t
.
getvalue
()
self
.
assertIn
(
'ustar/conttype'
,
out
)
self
.
assertIn
(
'ustar/regtype'
,
out
)
self
.
assertIn
(
'ustar/lnktype'
,
out
)
self
.
assertIn
(
'ustar'
+
(
'/12345'
*
40
)
+
'67/longname'
,
out
)
self
.
assertIn
(
'./ustar/linktest2/symtype'
,
out
)
self
.
assertIn
(
'./ustar/linktest2/lnktype'
,
out
)
# Make sure it puts trailing slash for directory
self
.
assertIn
(
'ustar/dirtype/'
,
out
)
self
.
assertIn
(
'ustar/dirtype-with-size/'
,
out
)
# Make sure it is able to print non-ASCII characters
self
.
assertIn
(
'ustar/umlauts-'
'
\xc4\xd6\xdc\xe4\xf6\xfc\xdf
'
,
out
)
self
.
assertIn
(
'misc/regtype-hpux-signed-chksum-'
'
\xc4\xd6\xdc\xe4\xf6\xfc\xdf
'
,
out
)
self
.
assertIn
(
'misc/regtype-old-v7-signed-chksum-'
'
\xc4\xd6\xdc\xe4\xf6\xfc\xdf
'
,
out
)
# Make sure it prints files separated by one newline without any
# 'ls -l'-like accessories if verbose flag is not being used
# ...
# ustar/conttype
# ustar/regtype
# ...
self
.
assertRegexpMatches
(
out
,
r'ustar/conttype ?\r?\n'
r'ustar/regtype ?\r?\n'
)
# Make sure it does not print the source of link without verbose flag
self
.
assertNotIn
(
'link to'
,
out
)
self
.
assertNotIn
(
'->'
,
out
)
def
test_list_verbose
(
self
):
with
test_support
.
captured_stdout
()
as
t
:
self
.
tar
.
list
(
verbose
=
True
)
out
=
t
.
getvalue
()
# Make sure it prints files separated by one newline with 'ls -l'-like
# accessories if verbose flag is being used
# ...
# ?rw-r--r-- tarfile/tarfile 7011 2003-01-06 07:19:43 ustar/conttype
# ?rw-r--r-- tarfile/tarfile 7011 2003-01-06 07:19:43 ustar/regtype
# ...
self
.
assertRegexpMatches
(
out
,
(
r'-rw-r--r-- tarfile/tarfile\s+7011 '
r'\d{4}-\d\d-\d\d\s+\d\d:\d\d:\d\d '
r'ustar/\w+type ?\r?\n'
)
*
2
)
# Make sure it prints the source of link with verbose flag
self
.
assertIn
(
'ustar/symtype -> regtype'
,
out
)
self
.
assertIn
(
'./ustar/linktest2/symtype -> ../linktest1/regtype'
,
out
)
self
.
assertIn
(
'./ustar/linktest2/lnktype link to '
'./ustar/linktest1/regtype'
,
out
)
self
.
assertIn
(
'gnu'
+
(
'/123'
*
125
)
+
'/longlink link to gnu'
+
(
'/123'
*
125
)
+
'/longname'
,
out
)
self
.
assertIn
(
'pax'
+
(
'/123'
*
125
)
+
'/longlink link to pax'
+
(
'/123'
*
125
)
+
'/longname'
,
out
)
class
GzipListTest
(
ListTest
):
tarname
=
gzipname
mode
=
"r:gz"
taropen
=
tarfile
.
TarFile
.
gzopen
class
Bz2ListTest
(
ListTest
):
tarname
=
bz2name
mode
=
"r:bz2"
taropen
=
tarfile
.
TarFile
.
bz2open
class
CommonReadTest
(
ReadTest
):
def
test_empty_tarfile
(
self
):
...
...
@@ -1646,6 +1720,7 @@ def test_main():
MemberReadTest
,
GNUReadTest
,
PaxReadTest
,
ListTest
,
WriteTest
,
StreamWriteTest
,
GNUWriteTest
,
...
...
@@ -1677,6 +1752,7 @@ def test_main():
GzipMiscReadTest
,
GzipUstarReadTest
,
GzipStreamReadTest
,
GzipListTest
,
GzipWriteTest
,
GzipStreamWriteTest
,
]
...
...
@@ -1691,6 +1767,7 @@ def test_main():
Bz2MiscReadTest
,
Bz2UstarReadTest
,
Bz2StreamReadTest
,
Bz2ListTest
,
Bz2WriteTest
,
Bz2StreamWriteTest
,
Bz2PartialReadTest
,
...
...
Misc/NEWS
Dosyayı görüntüle @
cfc2c7bb
...
...
@@ -224,6 +224,8 @@ IDLE
Tests
-----
- Issue #19920: Added tests for TarFile.list(). Based on patch by Vajrasky Kok.
- Issue #19990: Added tests for the imghdr module. Based on patch by
Claudiu Popa.
...
...
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