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
5acec04d
Kaydet (Commit)
5acec04d
authored
Eki 13, 2010
tarafından
Brian Curtin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Implement #7944. Use `with` throughout the test suite.
üst
28f96b5b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
23 deletions
+19
-23
test_mailbox.py
Lib/test/test_mailbox.py
+19
-23
No files found.
Lib/test/test_mailbox.py
Dosyayı görüntüle @
5acec04d
...
@@ -586,12 +586,10 @@ class TestMaildir(TestMailbox):
...
@@ -586,12 +586,10 @@ class TestMaildir(TestMailbox):
# Remove old files from 'tmp'
# Remove old files from 'tmp'
foo_path
=
os
.
path
.
join
(
self
.
_path
,
'tmp'
,
'foo'
)
foo_path
=
os
.
path
.
join
(
self
.
_path
,
'tmp'
,
'foo'
)
bar_path
=
os
.
path
.
join
(
self
.
_path
,
'tmp'
,
'bar'
)
bar_path
=
os
.
path
.
join
(
self
.
_path
,
'tmp'
,
'bar'
)
f
=
open
(
foo_path
,
'w'
)
with
open
(
foo_path
,
'w'
)
as
f
:
f
.
write
(
"@"
)
f
.
write
(
"@"
)
f
.
close
()
with
open
(
bar_path
,
'w'
)
as
f
:
f
=
open
(
bar_path
,
'w'
)
f
.
write
(
"@"
)
f
.
write
(
"@"
)
f
.
close
()
self
.
_box
.
clean
()
self
.
_box
.
clean
()
self
.
assertTrue
(
os
.
path
.
exists
(
foo_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
foo_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
bar_path
))
self
.
assertTrue
(
os
.
path
.
exists
(
bar_path
))
...
@@ -816,7 +814,8 @@ class _TestMboxMMDF(TestMailbox):
...
@@ -816,7 +814,8 @@ class _TestMboxMMDF(TestMailbox):
self
.
_box
.
_file
.
seek
(
0
)
self
.
_box
.
_file
.
seek
(
0
)
contents
=
self
.
_box
.
_file
.
read
()
contents
=
self
.
_box
.
_file
.
read
()
self
.
_box
.
close
()
self
.
_box
.
close
()
self
.
assertEqual
(
contents
,
open
(
self
.
_path
,
'r'
,
newline
=
''
)
.
read
())
with
open
(
self
.
_path
,
'r'
,
newline
=
''
)
as
f
:
self
.
assertEqual
(
contents
,
f
.
read
())
self
.
_box
=
self
.
_factory
(
self
.
_path
)
self
.
_box
=
self
.
_factory
(
self
.
_path
)
def
test_lock_conflict
(
self
):
def
test_lock_conflict
(
self
):
...
@@ -1077,13 +1076,12 @@ class TestMessage(TestBase):
...
@@ -1077,13 +1076,12 @@ class TestMessage(TestBase):
def
test_initialize_with_file
(
self
):
def
test_initialize_with_file
(
self
):
# Initialize based on contents of file
# Initialize based on contents of file
f
=
open
(
self
.
_path
,
'w+'
)
with
open
(
self
.
_path
,
'w+'
)
as
f
:
f
.
write
(
_sample_message
)
f
.
write
(
_sample_message
)
f
.
seek
(
0
)
f
.
seek
(
0
)
msg
=
self
.
_factory
(
f
)
msg
=
self
.
_factory
(
f
)
self
.
_post_initialize_hook
(
msg
)
self
.
_post_initialize_hook
(
msg
)
self
.
_check_sample
(
msg
)
self
.
_check_sample
(
msg
)
f
.
close
()
def
test_initialize_with_nothing
(
self
):
def
test_initialize_with_nothing
(
self
):
# Initialize without arguments
# Initialize without arguments
...
@@ -1807,18 +1805,16 @@ class MaildirTestCase(unittest.TestCase):
...
@@ -1807,18 +1805,16 @@ class MaildirTestCase(unittest.TestCase):
filename
=
"."
.
join
((
str
(
t
),
str
(
pid
),
"myhostname"
,
"mydomain"
))
filename
=
"."
.
join
((
str
(
t
),
str
(
pid
),
"myhostname"
,
"mydomain"
))
tmpname
=
os
.
path
.
join
(
self
.
_dir
,
"tmp"
,
filename
)
tmpname
=
os
.
path
.
join
(
self
.
_dir
,
"tmp"
,
filename
)
newname
=
os
.
path
.
join
(
self
.
_dir
,
dir
,
filename
)
newname
=
os
.
path
.
join
(
self
.
_dir
,
dir
,
filename
)
fp
=
open
(
tmpname
,
"w"
)
with
open
(
tmpname
,
"w"
)
as
fp
:
self
.
_msgfiles
.
append
(
tmpname
)
self
.
_msgfiles
.
append
(
tmpname
)
if
mbox
:
if
mbox
:
fp
.
write
(
FROM_
)
fp
.
write
(
FROM_
)
fp
.
write
(
DUMMY_MESSAGE
)
fp
.
write
(
DUMMY_MESSAGE
)
fp
.
close
()
if
hasattr
(
os
,
"link"
):
if
hasattr
(
os
,
"link"
):
os
.
link
(
tmpname
,
newname
)
os
.
link
(
tmpname
,
newname
)
else
:
else
:
fp
=
open
(
newname
,
"w"
)
with
open
(
newname
,
"w"
)
as
fp
:
fp
.
write
(
DUMMY_MESSAGE
)
fp
.
write
(
DUMMY_MESSAGE
)
fp
.
close
()
self
.
_msgfiles
.
append
(
newname
)
self
.
_msgfiles
.
append
(
newname
)
return
tmpname
return
tmpname
...
...
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