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
027f95c7
Unverified
Kaydet (Commit)
027f95c7
authored
Haz 03, 2018
tarafından
Serhiy Storchaka
Kaydeden (comit)
GitHub
Haz 03, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33744: Fix test_uu. (GH-7350)
Separate tests leaked files or were depended on files leaked in other tests.
üst
a801cf16
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
78 deletions
+26
-78
test_uu.py
Lib/test/test_uu.py
+26
-78
No files found.
Lib/test/test_uu.py
Dosyayı görüntüle @
027f95c7
...
...
@@ -6,7 +6,7 @@ Nick Mathewson
import
unittest
from
test
import
support
import
sys
,
os
import
sys
import
uu
import
io
...
...
@@ -162,113 +162,61 @@ class UUStdIOTest(unittest.TestCase):
class
UUFileTest
(
unittest
.
TestCase
):
def
_kill
(
self
,
f
):
# close and remove file
if
f
is
None
:
return
try
:
f
.
close
()
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
:
pass
try
:
os
.
unlink
(
f
.
name
)
except
(
SystemExit
,
KeyboardInterrupt
):
raise
except
:
pass
def
setUp
(
self
):
self
.
tmpin
=
support
.
TESTFN
+
"i"
self
.
tmpout
=
support
.
TESTFN
+
"o"
def
tearDown
(
self
):
del
self
.
tmpin
del
self
.
tmpout
self
.
addCleanup
(
support
.
unlink
,
self
.
tmpin
)
self
.
addCleanup
(
support
.
unlink
,
self
.
tmpout
)
def
test_encode
(
self
):
fin
=
fout
=
None
try
:
support
.
unlink
(
self
.
tmpin
)
fin
=
open
(
self
.
tmpin
,
'wb'
)
with
open
(
self
.
tmpin
,
'wb'
)
as
fin
:
fin
.
write
(
plaintext
)
fin
.
close
()
fin
=
open
(
self
.
tmpin
,
'rb'
)
fout
=
open
(
self
.
tmpout
,
'wb'
)
uu
.
encode
(
fin
,
fout
,
self
.
tmpin
,
mode
=
0
o644
)
fin
.
close
()
fout
.
close
()
with
open
(
self
.
tmpin
,
'rb'
)
as
fin
:
with
open
(
self
.
tmpout
,
'wb'
)
as
fout
:
uu
.
encode
(
fin
,
fout
,
self
.
tmpin
,
mode
=
0
o644
)
fout
=
open
(
self
.
tmpout
,
'rb'
)
with
open
(
self
.
tmpout
,
'rb'
)
as
fout
:
s
=
fout
.
read
()
fout
.
close
()
self
.
assertEqual
(
s
,
encodedtextwrapped
(
0
o644
,
self
.
tmpin
))
self
.
assertEqual
(
s
,
encodedtextwrapped
(
0
o644
,
self
.
tmpin
))
# in_file and out_file as filenames
uu
.
encode
(
self
.
tmpin
,
self
.
tmpout
,
self
.
tmpin
,
mode
=
0
o644
)
fout
=
open
(
self
.
tmpout
,
'rb'
)
# in_file and out_file as filenames
uu
.
encode
(
self
.
tmpin
,
self
.
tmpout
,
self
.
tmpin
,
mode
=
0
o644
)
with
open
(
self
.
tmpout
,
'rb'
)
as
fout
:
s
=
fout
.
read
()
fout
.
close
()
self
.
assertEqual
(
s
,
encodedtextwrapped
(
0
o644
,
self
.
tmpin
))
finally
:
self
.
_kill
(
fin
)
self
.
_kill
(
fout
)
self
.
assertEqual
(
s
,
encodedtextwrapped
(
0
o644
,
self
.
tmpin
))
def
test_decode
(
self
):
f
=
None
try
:
support
.
unlink
(
self
.
tmpin
)
f
=
open
(
self
.
tmpin
,
'wb'
)
with
open
(
self
.
tmpin
,
'wb'
)
as
f
:
f
.
write
(
encodedtextwrapped
(
0
o644
,
self
.
tmpout
))
f
.
close
()
f
=
open
(
self
.
tmpin
,
'rb'
)
with
open
(
self
.
tmpin
,
'rb'
)
as
f
:
uu
.
decode
(
f
)
f
.
close
()
f
=
open
(
self
.
tmpout
,
'rb'
)
with
open
(
self
.
tmpout
,
'rb'
)
as
f
:
s
=
f
.
read
()
f
.
close
()
self
.
assertEqual
(
s
,
plaintext
)
# XXX is there an xp way to verify the mode?
finally
:
self
.
_kill
(
f
)
self
.
assertEqual
(
s
,
plaintext
)
# XXX is there an xp way to verify the mode?
def
test_decode_filename
(
self
):
f
=
None
try
:
support
.
unlink
(
self
.
tmpin
)
f
=
open
(
self
.
tmpin
,
'wb'
)
with
open
(
self
.
tmpin
,
'wb'
)
as
f
:
f
.
write
(
encodedtextwrapped
(
0
o644
,
self
.
tmpout
))
f
.
close
()
uu
.
decode
(
self
.
tmpin
)
uu
.
decode
(
self
.
tmpin
)
f
=
open
(
self
.
tmpout
,
'rb'
)
with
open
(
self
.
tmpout
,
'rb'
)
as
f
:
s
=
f
.
read
()
f
.
close
()
self
.
assertEqual
(
s
,
plaintext
)
finally
:
self
.
_kill
(
f
)
self
.
assertEqual
(
s
,
plaintext
)
def
test_decodetwice
(
self
):
# Verify that decode() will refuse to overwrite an existing file
f
=
None
try
:
f
=
io
.
BytesIO
(
encodedtextwrapped
(
0
o644
,
self
.
tmpout
))
f
=
open
(
self
.
tmpin
,
'rb'
)
with
open
(
self
.
tmpin
,
'wb'
)
as
f
:
f
.
write
(
encodedtextwrapped
(
0
o644
,
self
.
tmpout
))
with
open
(
self
.
tmpin
,
'rb'
)
as
f
:
uu
.
decode
(
f
)
f
.
close
()
f
=
open
(
self
.
tmpin
,
'rb'
)
with
open
(
self
.
tmpin
,
'rb'
)
as
f
:
self
.
assertRaises
(
uu
.
Error
,
uu
.
decode
,
f
)
f
.
close
()
finally
:
self
.
_kill
(
f
)
if
__name__
==
"__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