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
1cae9ec9
Kaydet (Commit)
1cae9ec9
authored
Tem 14, 2014
tarafından
Victor Stinner
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
asyncio tests: make quiet the logs of SSL handshake failures when running tests
in debug mode
üst
acdb782a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
17 deletions
+37
-17
test_utils.py
Lib/asyncio/test_utils.py
+16
-0
test_events.py
Lib/test/test_asyncio/test_events.py
+13
-10
test_selector_events.py
Lib/test/test_asyncio/test_selector_events.py
+8
-7
No files found.
Lib/asyncio/test_utils.py
Dosyayı görüntüle @
1cae9ec9
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
collections
import
collections
import
contextlib
import
contextlib
import
io
import
io
import
logging
import
os
import
os
import
re
import
re
import
socket
import
socket
...
@@ -28,6 +29,7 @@ from . import futures
...
@@ -28,6 +29,7 @@ from . import futures
from
.
import
selectors
from
.
import
selectors
from
.
import
tasks
from
.
import
tasks
from
.coroutines
import
coroutine
from
.coroutines
import
coroutine
from
.log
import
logger
if
sys
.
platform
==
'win32'
:
# pragma: no cover
if
sys
.
platform
==
'win32'
:
# pragma: no cover
...
@@ -401,3 +403,17 @@ class TestCase(unittest.TestCase):
...
@@ -401,3 +403,17 @@ class TestCase(unittest.TestCase):
def
tearDown
(
self
):
def
tearDown
(
self
):
events
.
set_event_loop
(
None
)
events
.
set_event_loop
(
None
)
@contextlib.contextmanager
def
disable_logger
():
"""Context manager to disable asyncio logger.
For example, it can be used to ignore warnings in debug mode.
"""
old_level
=
logger
.
level
try
:
logger
.
setLevel
(
logging
.
CRITICAL
+
1
)
yield
finally
:
logger
.
setLevel
(
old_level
)
Lib/test/test_asyncio/test_events.py
Dosyayı görüntüle @
1cae9ec9
...
@@ -819,9 +819,10 @@ class EventLoopTestsMixin:
...
@@ -819,9 +819,10 @@ class EventLoopTestsMixin:
# no CA loaded
# no CA loaded
f_c
=
self
.
loop
.
create_connection
(
MyProto
,
host
,
port
,
f_c
=
self
.
loop
.
create_connection
(
MyProto
,
host
,
port
,
ssl
=
sslcontext_client
)
ssl
=
sslcontext_client
)
with
self
.
assertRaisesRegex
(
ssl
.
SSLError
,
with
test_utils
.
disable_logger
():
'certificate verify failed '
):
with
self
.
assertRaisesRegex
(
ssl
.
SSLError
,
self
.
loop
.
run_until_complete
(
f_c
)
'certificate verify failed '
):
self
.
loop
.
run_until_complete
(
f_c
)
# close connection
# close connection
self
.
assertIsNone
(
proto
.
transport
)
self
.
assertIsNone
(
proto
.
transport
)
...
@@ -845,9 +846,10 @@ class EventLoopTestsMixin:
...
@@ -845,9 +846,10 @@ class EventLoopTestsMixin:
f_c
=
self
.
loop
.
create_unix_connection
(
MyProto
,
path
,
f_c
=
self
.
loop
.
create_unix_connection
(
MyProto
,
path
,
ssl
=
sslcontext_client
,
ssl
=
sslcontext_client
,
server_hostname
=
'invalid'
)
server_hostname
=
'invalid'
)
with
self
.
assertRaisesRegex
(
ssl
.
SSLError
,
with
test_utils
.
disable_logger
():
'certificate verify failed '
):
with
self
.
assertRaisesRegex
(
ssl
.
SSLError
,
self
.
loop
.
run_until_complete
(
f_c
)
'certificate verify failed '
):
self
.
loop
.
run_until_complete
(
f_c
)
# close connection
# close connection
self
.
assertIsNone
(
proto
.
transport
)
self
.
assertIsNone
(
proto
.
transport
)
...
@@ -871,10 +873,11 @@ class EventLoopTestsMixin:
...
@@ -871,10 +873,11 @@ class EventLoopTestsMixin:
# incorrect server_hostname
# incorrect server_hostname
f_c
=
self
.
loop
.
create_connection
(
MyProto
,
host
,
port
,
f_c
=
self
.
loop
.
create_connection
(
MyProto
,
host
,
port
,
ssl
=
sslcontext_client
)
ssl
=
sslcontext_client
)
with
self
.
assertRaisesRegex
(
with
test_utils
.
disable_logger
():
ssl
.
CertificateError
,
with
self
.
assertRaisesRegex
(
"hostname '127.0.0.1' doesn't match 'localhost'"
):
ssl
.
CertificateError
,
self
.
loop
.
run_until_complete
(
f_c
)
"hostname '127.0.0.1' doesn't match 'localhost'"
):
self
.
loop
.
run_until_complete
(
f_c
)
# close connection
# close connection
proto
.
transport
.
close
()
proto
.
transport
.
close
()
...
...
Lib/test/test_asyncio/test_selector_events.py
Dosyayı görüntüle @
1cae9ec9
...
@@ -1105,13 +1105,13 @@ class SelectorSslTransportTests(test_utils.TestCase):
...
@@ -1105,13 +1105,13 @@ class SelectorSslTransportTests(test_utils.TestCase):
def
test_on_handshake_exc
(
self
):
def
test_on_handshake_exc
(
self
):
exc
=
ValueError
()
exc
=
ValueError
()
self
.
sslsock
.
do_handshake
.
side_effect
=
exc
self
.
sslsock
.
do_handshake
.
side_effect
=
exc
transport
=
_SelectorSslTransport
(
with
test_utils
.
disable_logger
():
self
.
loop
,
self
.
sock
,
self
.
protocol
,
self
.
sslcontext
)
waiter
=
asyncio
.
Future
(
loop
=
self
.
loop
)
transport
.
_waiter
=
asyncio
.
Future
(
loop
=
self
.
loop
)
transport
=
_SelectorSslTransport
(
transport
.
_on_handshake
(
None
)
self
.
loop
,
self
.
sock
,
self
.
protocol
,
self
.
sslcontext
,
waiter
)
self
.
assertTrue
(
waiter
.
done
())
self
.
assertIs
(
exc
,
waiter
.
exception
())
self
.
assertTrue
(
self
.
sslsock
.
close
.
called
)
self
.
assertTrue
(
self
.
sslsock
.
close
.
called
)
self
.
assertTrue
(
transport
.
_waiter
.
done
())
self
.
assertIs
(
exc
,
transport
.
_waiter
.
exception
())
def
test_on_handshake_base_exc
(
self
):
def
test_on_handshake_base_exc
(
self
):
transport
=
_SelectorSslTransport
(
transport
=
_SelectorSslTransport
(
...
@@ -1119,7 +1119,8 @@ class SelectorSslTransportTests(test_utils.TestCase):
...
@@ -1119,7 +1119,8 @@ class SelectorSslTransportTests(test_utils.TestCase):
transport
.
_waiter
=
asyncio
.
Future
(
loop
=
self
.
loop
)
transport
.
_waiter
=
asyncio
.
Future
(
loop
=
self
.
loop
)
exc
=
BaseException
()
exc
=
BaseException
()
self
.
sslsock
.
do_handshake
.
side_effect
=
exc
self
.
sslsock
.
do_handshake
.
side_effect
=
exc
self
.
assertRaises
(
BaseException
,
transport
.
_on_handshake
,
None
)
with
test_utils
.
disable_logger
():
self
.
assertRaises
(
BaseException
,
transport
.
_on_handshake
,
None
)
self
.
assertTrue
(
self
.
sslsock
.
close
.
called
)
self
.
assertTrue
(
self
.
sslsock
.
close
.
called
)
self
.
assertTrue
(
transport
.
_waiter
.
done
())
self
.
assertTrue
(
transport
.
_waiter
.
done
())
self
.
assertIs
(
exc
,
transport
.
_waiter
.
exception
())
self
.
assertIs
(
exc
,
transport
.
_waiter
.
exception
())
...
...
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