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
6b98544b
Kaydet (Commit)
6b98544b
authored
May 29, 2009
tarafından
R. David Murray
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor test parameterization to resolve update timing problem.
üst
4f16d3b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
14 deletions
+13
-14
test_smtplib.py
Lib/test/test_smtplib.py
+13
-14
No files found.
Lib/test/test_smtplib.py
Dosyayı görüntüle @
6b98544b
...
@@ -294,17 +294,11 @@ sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'],
...
@@ -294,17 +294,11 @@ sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'],
# Simulated SMTP channel & server
# Simulated SMTP channel & server
class
SimSMTPChannel
(
smtpd
.
SMTPChannel
):
class
SimSMTPChannel
(
smtpd
.
SMTPChannel
):
def
__init__
(
self
,
*
args
,
**
kw
):
def
__init__
(
self
,
extra_features
,
*
args
,
**
kw
):
self
.
__extrafeatures
=
[]
self
.
_extrafeatures
=
''
.
join
(
[
"250-{0}
\r\n
"
.
format
(
x
)
for
x
in
extra_features
])
smtpd
.
SMTPChannel
.
__init__
(
self
,
*
args
,
**
kw
)
smtpd
.
SMTPChannel
.
__init__
(
self
,
*
args
,
**
kw
)
@property
def
_extrafeatures
(
self
):
return
''
.
join
([
"250-{0}
\r\n
"
.
format
(
x
)
for
x
in
self
.
__extrafeatures
])
def
add_feature
(
self
,
feature
):
self
.
__extrafeatures
.
append
(
feature
)
def
smtp_EHLO
(
self
,
arg
):
def
smtp_EHLO
(
self
,
arg
):
resp
=
(
'250-testhost
\r\n
'
resp
=
(
'250-testhost
\r\n
'
'250-EXPN
\r\n
'
'250-EXPN
\r\n
'
...
@@ -354,15 +348,20 @@ class SimSMTPChannel(smtpd.SMTPChannel):
...
@@ -354,15 +348,20 @@ class SimSMTPChannel(smtpd.SMTPChannel):
class
SimSMTPServer
(
smtpd
.
SMTPServer
):
class
SimSMTPServer
(
smtpd
.
SMTPServer
):
def
__init__
(
self
,
*
args
,
**
kw
):
self
.
_extra_features
=
[]
smtpd
.
SMTPServer
.
__init__
(
self
,
*
args
,
**
kw
)
def
handle_accept
(
self
):
def
handle_accept
(
self
):
conn
,
addr
=
self
.
accept
()
conn
,
addr
=
self
.
accept
()
self
.
_SMTPchannel
=
SimSMTPChannel
(
self
,
conn
,
addr
)
self
.
_SMTPchannel
=
SimSMTPChannel
(
self
.
_extra_features
,
self
,
conn
,
addr
)
def
process_message
(
self
,
peer
,
mailfrom
,
rcpttos
,
data
):
def
process_message
(
self
,
peer
,
mailfrom
,
rcpttos
,
data
):
pass
pass
def
add_feature
(
self
,
feature
):
def
add_feature
(
self
,
feature
):
self
.
_
SMTPchannel
.
add_feature
(
feature
)
self
.
_
extra_features
.
append
(
feature
)
# Test various SMTP & ESMTP commands/behaviors that require a simulated server
# Test various SMTP & ESMTP commands/behaviors that require a simulated server
...
@@ -441,8 +440,8 @@ class SMTPSimTests(TestCase):
...
@@ -441,8 +440,8 @@ class SMTPSimTests(TestCase):
smtp
.
quit
()
smtp
.
quit
()
def
testAUTH_PLAIN
(
self
):
def
testAUTH_PLAIN
(
self
):
smtp
=
smtplib
.
SMTP
(
HOST
,
self
.
port
,
local_hostname
=
'localhost'
,
timeout
=
15
)
self
.
serv
.
add_feature
(
"AUTH PLAIN"
)
self
.
serv
.
add_feature
(
"AUTH PLAIN"
)
smtp
=
smtplib
.
SMTP
(
HOST
,
self
.
port
,
local_hostname
=
'localhost'
,
timeout
=
15
)
expected_auth_ok
=
(
235
,
b
'plain auth ok'
)
expected_auth_ok
=
(
235
,
b
'plain auth ok'
)
self
.
assertEqual
(
smtp
.
login
(
sim_auth
[
0
],
sim_auth
[
1
]),
expected_auth_ok
)
self
.
assertEqual
(
smtp
.
login
(
sim_auth
[
0
],
sim_auth
[
1
]),
expected_auth_ok
)
...
@@ -456,16 +455,16 @@ class SMTPSimTests(TestCase):
...
@@ -456,16 +455,16 @@ class SMTPSimTests(TestCase):
# the error message).
# the error message).
def
testAUTH_LOGIN
(
self
):
def
testAUTH_LOGIN
(
self
):
smtp
=
smtplib
.
SMTP
(
HOST
,
self
.
port
,
local_hostname
=
'localhost'
,
timeout
=
15
)
self
.
serv
.
add_feature
(
"AUTH LOGIN"
)
self
.
serv
.
add_feature
(
"AUTH LOGIN"
)
smtp
=
smtplib
.
SMTP
(
HOST
,
self
.
port
,
local_hostname
=
'localhost'
,
timeout
=
15
)
try
:
smtp
.
login
(
sim_auth
[
0
],
sim_auth
[
1
])
try
:
smtp
.
login
(
sim_auth
[
0
],
sim_auth
[
1
])
except
smtplib
.
SMTPAuthenticationError
as
err
:
except
smtplib
.
SMTPAuthenticationError
as
err
:
if
sim_auth_login_password
not
in
str
(
err
):
if
sim_auth_login_password
not
in
str
(
err
):
raise
"expected encoded password not found in error message"
raise
"expected encoded password not found in error message"
def
testAUTH_CRAM_MD5
(
self
):
def
testAUTH_CRAM_MD5
(
self
):
smtp
=
smtplib
.
SMTP
(
HOST
,
self
.
port
,
local_hostname
=
'localhost'
,
timeout
=
15
)
self
.
serv
.
add_feature
(
"AUTH CRAM-MD5"
)
self
.
serv
.
add_feature
(
"AUTH CRAM-MD5"
)
smtp
=
smtplib
.
SMTP
(
HOST
,
self
.
port
,
local_hostname
=
'localhost'
,
timeout
=
15
)
try
:
smtp
.
login
(
sim_auth
[
0
],
sim_auth
[
1
])
try
:
smtp
.
login
(
sim_auth
[
0
],
sim_auth
[
1
])
except
smtplib
.
SMTPAuthenticationError
as
err
:
except
smtplib
.
SMTPAuthenticationError
as
err
:
...
...
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