Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
fc29e0f3
Commit
fc29e0f3
authored
Oct 17, 2013
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename the logger to plain "logger".
parent
b795aa85
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
61 additions
and
60 deletions
+61
-60
Lib/asyncio/base_events.py
Lib/asyncio/base_events.py
+2
-2
Lib/asyncio/events.py
Lib/asyncio/events.py
+3
-3
Lib/asyncio/futures.py
Lib/asyncio/futures.py
+3
-3
Lib/asyncio/log.py
Lib/asyncio/log.py
+2
-1
Lib/asyncio/proactor_events.py
Lib/asyncio/proactor_events.py
+5
-5
Lib/asyncio/selector_events.py
Lib/asyncio/selector_events.py
+7
-7
Lib/asyncio/tasks.py
Lib/asyncio/tasks.py
+3
-3
Lib/asyncio/unix_events.py
Lib/asyncio/unix_events.py
+8
-8
Lib/asyncio/windows_events.py
Lib/asyncio/windows_events.py
+3
-3
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+2
-2
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_events.py
+1
-1
Lib/test/test_asyncio/test_futures.py
Lib/test/test_asyncio/test_futures.py
+6
-6
Lib/test/test_asyncio/test_proactor_events.py
Lib/test/test_asyncio/test_proactor_events.py
+3
-3
Lib/test/test_asyncio/test_selector_events.py
Lib/test/test_asyncio/test_selector_events.py
+6
-6
Lib/test/test_asyncio/test_unix_events.py
Lib/test/test_asyncio/test_unix_events.py
+7
-7
No files found.
Lib/asyncio/base_events.py
View file @
fc29e0f3
...
...
@@ -27,7 +27,7 @@ import sys
from
.
import
events
from
.
import
futures
from
.
import
tasks
from
.log
import
asyncio_log
from
.log
import
logger
__all__
=
[
'BaseEventLoop'
,
'Server'
]
...
...
@@ -580,7 +580,7 @@ class BaseEventLoop(events.AbstractEventLoop):
level
=
logging
.
INFO
else
:
level
=
logging
.
DEBUG
asyncio_log
.
log
(
level
,
'poll%s took %.3f seconds'
,
argstr
,
t1
-
t0
)
logger
.
log
(
level
,
'poll%s took %.3f seconds'
,
argstr
,
t1
-
t0
)
self
.
_process_events
(
event_list
)
# Handle 'later' callbacks that are ready.
...
...
Lib/asyncio/events.py
View file @
fc29e0f3
...
...
@@ -12,7 +12,7 @@ import sys
import
threading
import
socket
from
.log
import
asyncio_log
from
.log
import
logger
class
Handle
:
...
...
@@ -36,8 +36,8 @@ class Handle:
try
:
self
.
_callback
(
*
self
.
_args
)
except
Exception
:
asyncio_log
.
exception
(
'Exception in callback %s %r'
,
self
.
_callback
,
self
.
_args
)
logger
.
exception
(
'Exception in callback %s %r'
,
self
.
_callback
,
self
.
_args
)
self
=
None
# Needed to break cycles when an exception occurs.
...
...
Lib/asyncio/futures.py
View file @
fc29e0f3
...
...
@@ -10,7 +10,7 @@ import logging
import
traceback
from
.
import
events
from
.log
import
asyncio_log
from
.log
import
logger
# States for Future.
_PENDING
=
'PENDING'
...
...
@@ -99,8 +99,8 @@ class _TracebackLogger:
def
__del__
(
self
):
if
self
.
tb
:
asyncio_log
.
error
(
'Future/Task exception was never retrieved:
\
n
%s'
,
''
.
join
(
self
.
tb
))
logger
.
error
(
'Future/Task exception was never retrieved:
\
n
%s'
,
''
.
join
(
self
.
tb
))
class
Future
:
...
...
Lib/asyncio/log.py
View file @
fc29e0f3
...
...
@@ -3,4 +3,5 @@
import
logging
asyncio_log
=
logging
.
getLogger
(
"asyncio"
)
# Name the logger after the package.
logger
=
logging
.
getLogger
(
__package__
)
Lib/asyncio/proactor_events.py
View file @
fc29e0f3
...
...
@@ -10,7 +10,7 @@ from . import base_events
from
.
import
constants
from
.
import
futures
from
.
import
transports
from
.log
import
asyncio_log
from
.log
import
logger
class
_ProactorBasePipeTransport
(
transports
.
BaseTransport
):
...
...
@@ -50,7 +50,7 @@ class _ProactorBasePipeTransport(transports.BaseTransport):
self
.
_read_fut
.
cancel
()
def
_fatal_error
(
self
,
exc
):
asyncio_log
.
exception
(
'Fatal error for %s'
,
self
)
logger
.
exception
(
'Fatal error for %s'
,
self
)
self
.
_force_close
(
exc
)
def
_force_close
(
self
,
exc
):
...
...
@@ -164,7 +164,7 @@ class _ProactorWritePipeTransport(_ProactorBasePipeTransport,
if
self
.
_conn_lost
:
if
self
.
_conn_lost
>=
constants
.
LOG_THRESHOLD_FOR_CONNLOST_WRITES
:
asyncio_log
.
warning
(
'socket.send() raised exception.'
)
logger
.
warning
(
'socket.send() raised exception.'
)
self
.
_conn_lost
+=
1
return
self
.
_buffer
.
append
(
data
)
...
...
@@ -246,7 +246,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
def
__init__
(
self
,
proactor
):
super
().
__init__
()
asyncio_log
.
debug
(
'Using proactor: %s'
,
proactor
.
__class__
.
__name__
)
logger
.
debug
(
'Using proactor: %s'
,
proactor
.
__class__
.
__name__
)
self
.
_proactor
=
proactor
self
.
_selector
=
proactor
# convenient alias
proactor
.
set_loop
(
self
)
...
...
@@ -335,7 +335,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
f
=
self
.
_proactor
.
accept
(
sock
)
except
OSError
:
if
sock
.
fileno
()
!=
-
1
:
asyncio_log
.
exception
(
'Accept failed'
)
logger
.
exception
(
'Accept failed'
)
sock
.
close
()
except
futures
.
CancelledError
:
sock
.
close
()
...
...
Lib/asyncio/selector_events.py
View file @
fc29e0f3
...
...
@@ -17,7 +17,7 @@ from . import events
from
.
import
futures
from
.
import
selectors
from
.
import
transports
from
.log
import
asyncio_log
from
.log
import
logger
class
BaseSelectorEventLoop
(
base_events
.
BaseEventLoop
):
...
...
@@ -31,7 +31,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
if
selector
is
None
:
selector
=
selectors
.
DefaultSelector
()
asyncio_log
.
debug
(
'Using selector: %s'
,
selector
.
__class__
.
__name__
)
logger
.
debug
(
'Using selector: %s'
,
selector
.
__class__
.
__name__
)
self
.
_selector
=
selector
self
.
_make_self_pipe
()
...
...
@@ -105,7 +105,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
sock
.
close
()
# There's nowhere to send the error, so just log it.
# TODO: Someone will want an error handler for this.
asyncio_log
.
exception
(
'Accept failed'
)
logger
.
exception
(
'Accept failed'
)
else
:
if
ssl
:
self
.
_make_ssl_transport
(
...
...
@@ -363,7 +363,7 @@ class _SelectorTransport(transports.Transport):
def
_fatal_error
(
self
,
exc
):
# should be called from exception handler only
asyncio_log
.
exception
(
'Fatal error for %s'
,
self
)
logger
.
exception
(
'Fatal error for %s'
,
self
)
self
.
_force_close
(
exc
)
def
_force_close
(
self
,
exc
):
...
...
@@ -444,7 +444,7 @@ class _SelectorSocketTransport(_SelectorTransport):
if
self
.
_conn_lost
:
if
self
.
_conn_lost
>=
constants
.
LOG_THRESHOLD_FOR_CONNLOST_WRITES
:
asyncio_log
.
warning
(
'socket.send() raised exception.'
)
logger
.
warning
(
'socket.send() raised exception.'
)
self
.
_conn_lost
+=
1
return
...
...
@@ -667,7 +667,7 @@ class _SelectorSslTransport(_SelectorTransport):
if
self
.
_conn_lost
:
if
self
.
_conn_lost
>=
constants
.
LOG_THRESHOLD_FOR_CONNLOST_WRITES
:
asyncio_log
.
warning
(
'socket.send() raised exception.'
)
logger
.
warning
(
'socket.send() raised exception.'
)
self
.
_conn_lost
+=
1
return
...
...
@@ -714,7 +714,7 @@ class _SelectorDatagramTransport(_SelectorTransport):
if
self
.
_conn_lost
and
self
.
_address
:
if
self
.
_conn_lost
>=
constants
.
LOG_THRESHOLD_FOR_CONNLOST_WRITES
:
asyncio_log
.
warning
(
'socket.send() raised exception.'
)
logger
.
warning
(
'socket.send() raised exception.'
)
self
.
_conn_lost
+=
1
return
...
...
Lib/asyncio/tasks.py
View file @
fc29e0f3
...
...
@@ -16,7 +16,7 @@ import weakref
from
.
import
events
from
.
import
futures
from
.log
import
asyncio_log
from
.log
import
logger
# If you set _DEBUG to true, @coroutine will wrap the resulting
# generator objects in a CoroWrapper instance (defined below). That
...
...
@@ -62,8 +62,8 @@ class CoroWrapper:
code
=
func
.
__code__
filename
=
code
.
co_filename
lineno
=
code
.
co_firstlineno
asyncio_log
.
error
(
'Coroutine %r defined at %s:%s was never yielded from'
,
func
.
__name__
,
filename
,
lineno
)
logger
.
error
(
'Coroutine %r defined at %s:%s was never yielded from'
,
func
.
__name__
,
filename
,
lineno
)
def
coroutine
(
func
):
...
...
Lib/asyncio/unix_events.py
View file @
fc29e0f3
...
...
@@ -18,7 +18,7 @@ from . import protocols
from
.
import
selector_events
from
.
import
tasks
from
.
import
transports
from
.log
import
asyncio_log
from
.log
import
logger
__all__
=
[
'SelectorEventLoop'
,
'STDIN'
,
'STDOUT'
,
'STDERR'
]
...
...
@@ -79,7 +79,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
try
:
signal
.
set_wakeup_fd
(
-
1
)
except
ValueError
as
nexc
:
asyncio_log
.
info
(
'set_wakeup_fd(-1) failed: %s'
,
nexc
)
logger
.
info
(
'set_wakeup_fd(-1) failed: %s'
,
nexc
)
if
exc
.
errno
==
errno
.
EINVAL
:
raise
RuntimeError
(
'sig {} cannot be caught'
.
format
(
sig
))
...
...
@@ -124,7 +124,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
try
:
signal
.
set_wakeup_fd
(
-
1
)
except
ValueError
as
exc
:
asyncio_log
.
info
(
'set_wakeup_fd(-1) failed: %s'
,
exc
)
logger
.
info
(
'set_wakeup_fd(-1) failed: %s'
,
exc
)
return
True
...
...
@@ -185,7 +185,7 @@ class SelectorEventLoop(selector_events.BaseSelectorEventLoop):
if
transp
is
not
None
:
transp
.
_process_exited
(
returncode
)
except
Exception
:
asyncio_log
.
exception
(
'Unknown exception in SIGCHLD handler'
)
logger
.
exception
(
'Unknown exception in SIGCHLD handler'
)
def
_subprocess_closed
(
self
,
transport
):
pid
=
transport
.
get_pid
()
...
...
@@ -244,7 +244,7 @@ class _UnixReadPipeTransport(transports.ReadTransport):
def
_fatal_error
(
self
,
exc
):
# should be called by exception handler only
asyncio_log
.
exception
(
'Fatal error for %s'
,
self
)
logger
.
exception
(
'Fatal error for %s'
,
self
)
self
.
_close
(
exc
)
def
_close
(
self
,
exc
):
...
...
@@ -294,8 +294,8 @@ class _UnixWritePipeTransport(transports.WriteTransport):
if
self
.
_conn_lost
or
self
.
_closing
:
if
self
.
_conn_lost
>=
constants
.
LOG_THRESHOLD_FOR_CONNLOST_WRITES
:
asyncio_log
.
warning
(
'pipe closed by peer or '
'os.write(pipe, data) raised exception.'
)
logger
.
warning
(
'pipe closed by peer or '
'os.write(pipe, data) raised exception.'
)
self
.
_conn_lost
+=
1
return
...
...
@@ -369,7 +369,7 @@ class _UnixWritePipeTransport(transports.WriteTransport):
def
_fatal_error
(
self
,
exc
):
# should be called by exception handler only
asyncio_log
.
exception
(
'Fatal error for %s'
,
self
)
logger
.
exception
(
'Fatal error for %s'
,
self
)
self
.
_close
(
exc
)
def
_close
(
self
,
exc
=
None
):
...
...
Lib/asyncio/windows_events.py
View file @
fc29e0f3
...
...
@@ -11,7 +11,7 @@ from . import proactor_events
from
.
import
selector_events
from
.
import
tasks
from
.
import
windows_utils
from
.log
import
asyncio_log
from
.log
import
logger
try
:
import
_overlapped
...
...
@@ -139,7 +139,7 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
f
=
self
.
_proactor
.
accept_pipe
(
pipe
)
except
OSError
:
if
pipe
and
pipe
.
fileno
()
!=
-
1
:
asyncio_log
.
exception
(
'Pipe accept failed'
)
logger
.
exception
(
'Pipe accept failed'
)
pipe
.
close
()
except
futures
.
CancelledError
:
if
pipe
:
...
...
@@ -367,7 +367,7 @@ class IocpProactor:
while
self
.
_cache
:
if
not
self
.
_poll
(
1
):
asyncio_log
.
debug
(
'taking long time to close proactor'
)
logger
.
debug
(
'taking long time to close proactor'
)
self
.
_results
=
[]
if
self
.
_iocp
is
not
None
:
...
...
Lib/test/test_asyncio/test_base_events.py
View file @
fc29e0f3
...
...
@@ -183,7 +183,7 @@ class BaseEventLoopTests(unittest.TestCase):
self
.
assertTrue
(
self
.
loop
.
_process_events
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.base_events.time'
)
@
unittest
.
mock
.
patch
(
'asyncio.base_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.base_events.
logger
'
)
def
test__run_once_logging
(
self
,
m_logging
,
m_time
):
# Log to INFO level if timeout > 1.0 sec.
idx
=
-
1
...
...
@@ -579,7 +579,7 @@ class BaseEventLoopWithSelectorTests(unittest.TestCase):
self
.
loop
.
_accept_connection
(
MyProto
,
sock
)
self
.
assertFalse
(
sock
.
close
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
logger
'
)
def
test_accept_connection_exception
(
self
,
m_log
):
sock
=
unittest
.
mock
.
Mock
()
sock
.
fileno
.
return_value
=
10
...
...
Lib/test/test_asyncio/test_events.py
View file @
fc29e0f3
...
...
@@ -1320,7 +1320,7 @@ class HandleTests(unittest.TestCase):
self
.
assertRaises
(
AssertionError
,
events
.
make_handle
,
h1
,
())
@
unittest
.
mock
.
patch
(
'asyncio.events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.events.
logger
'
)
def
test_callback_with_exception
(
self
,
log
):
def
callback
():
raise
ValueError
()
...
...
Lib/test/test_asyncio/test_futures.py
View file @
fc29e0f3
...
...
@@ -170,20 +170,20 @@ class FutureTests(unittest.TestCase):
self
.
assertRaises
(
AssertionError
,
test
)
fut
.
cancel
()
@
unittest
.
mock
.
patch
(
'asyncio.futures.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
logger
'
)
def
test_tb_logger_abandoned
(
self
,
m_log
):
fut
=
futures
.
Future
(
loop
=
self
.
loop
)
del
fut
self
.
assertFalse
(
m_log
.
error
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
logger
'
)
def
test_tb_logger_result_unretrieved
(
self
,
m_log
):
fut
=
futures
.
Future
(
loop
=
self
.
loop
)
fut
.
set_result
(
42
)
del
fut
self
.
assertFalse
(
m_log
.
error
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
logger
'
)
def
test_tb_logger_result_retrieved
(
self
,
m_log
):
fut
=
futures
.
Future
(
loop
=
self
.
loop
)
fut
.
set_result
(
42
)
...
...
@@ -191,7 +191,7 @@ class FutureTests(unittest.TestCase):
del
fut
self
.
assertFalse
(
m_log
.
error
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
logger
'
)
def
test_tb_logger_exception_unretrieved
(
self
,
m_log
):
fut
=
futures
.
Future
(
loop
=
self
.
loop
)
fut
.
set_exception
(
RuntimeError
(
'boom'
))
...
...
@@ -199,7 +199,7 @@ class FutureTests(unittest.TestCase):
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertTrue
(
m_log
.
error
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
logger
'
)
def
test_tb_logger_exception_retrieved
(
self
,
m_log
):
fut
=
futures
.
Future
(
loop
=
self
.
loop
)
fut
.
set_exception
(
RuntimeError
(
'boom'
))
...
...
@@ -207,7 +207,7 @@ class FutureTests(unittest.TestCase):
del
fut
self
.
assertFalse
(
m_log
.
error
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.futures.
logger
'
)
def
test_tb_logger_exception_result_retrieved
(
self
,
m_log
):
fut
=
futures
.
Future
(
loop
=
self
.
loop
)
fut
.
set_exception
(
RuntimeError
(
'boom'
))
...
...
Lib/test/test_asyncio/test_proactor_events.py
View file @
fc29e0f3
...
...
@@ -135,7 +135,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
self
.
loop
.
_proactor
.
send
.
return_value
.
add_done_callback
.
\
assert_called_with
(
tr
.
_loop_writing
)
@
unittest
.
mock
.
patch
(
'asyncio.proactor_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.proactor_events.
logger
'
)
def
test_loop_writing_err
(
self
,
m_log
):
err
=
self
.
loop
.
_proactor
.
send
.
side_effect
=
OSError
()
tr
=
_ProactorSocketTransport
(
self
.
loop
,
self
.
sock
,
self
.
protocol
)
...
...
@@ -207,7 +207,7 @@ class ProactorSocketTransportTests(unittest.TestCase):
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertFalse
(
self
.
protocol
.
connection_lost
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.proactor_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.proactor_events.
logger
'
)
def
test_fatal_error
(
self
,
m_logging
):
tr
=
_ProactorSocketTransport
(
self
.
loop
,
self
.
sock
,
self
.
protocol
)
tr
.
_force_close
=
unittest
.
mock
.
Mock
()
...
...
@@ -432,7 +432,7 @@ class BaseProactorEventLoopTests(unittest.TestCase):
def
test_process_events
(
self
):
self
.
loop
.
_process_events
([])
@
unittest
.
mock
.
patch
(
'asyncio.proactor_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.proactor_events.
logger
'
)
def
test_create_server
(
self
,
m_log
):
pf
=
unittest
.
mock
.
Mock
()
call_soon
=
self
.
loop
.
call_soon
=
unittest
.
mock
.
Mock
()
...
...
Lib/test/test_asyncio/test_selector_events.py
View file @
fc29e0f3
...
...
@@ -626,7 +626,7 @@ class SelectorTransportTests(unittest.TestCase):
self
.
assertFalse
(
self
.
loop
.
readers
)
self
.
assertEqual
(
1
,
self
.
loop
.
remove_reader_count
[
7
])
@
unittest
.
mock
.
patch
(
'asyncio.log.
asyncio_log
.exception'
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
logger
.exception'
)
def
test_fatal_error
(
self
,
m_exc
):
exc
=
OSError
()
tr
=
_SelectorTransport
(
self
.
loop
,
self
.
sock
,
self
.
protocol
,
None
)
...
...
@@ -823,7 +823,7 @@ class SelectorSocketTransportTests(unittest.TestCase):
self
.
loop
.
assert_writer
(
7
,
transport
.
_write_ready
)
self
.
assertEqual
(
collections
.
deque
([
b'data'
]),
transport
.
_buffer
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
logger
'
)
def
test_write_exception
(
self
,
m_log
):
err
=
self
.
sock
.
send
.
side_effect
=
OSError
()
...
...
@@ -937,7 +937,7 @@ class SelectorSocketTransportTests(unittest.TestCase):
transport
.
_write_ready
()
transport
.
_fatal_error
.
assert_called_with
(
err
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
logger
'
)
def
test_write_ready_exception_and_close
(
self
,
m_log
):
self
.
sock
.
send
.
side_effect
=
OSError
()
remove_writer
=
self
.
loop
.
remove_writer
=
unittest
.
mock
.
Mock
()
...
...
@@ -1072,7 +1072,7 @@ class SelectorSslTransportTests(unittest.TestCase):
transport
.
write
(
b'data'
)
self
.
assertEqual
(
transport
.
_conn_lost
,
2
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
logger
'
)
def
test_write_exception
(
self
,
m_log
):
transport
=
self
.
_make_one
()
transport
.
_conn_lost
=
1
...
...
@@ -1325,7 +1325,7 @@ class SelectorDatagramTransportTests(unittest.TestCase):
self
.
assertEqual
(
[(
b'data'
,
(
'0.0.0.0'
,
12345
))],
list
(
transport
.
_buffer
))
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.selector_events.
logger
'
)
def
test_sendto_exception
(
self
,
m_log
):
data
=
b'data'
err
=
self
.
sock
.
sendto
.
side_effect
=
OSError
()
...
...
@@ -1475,7 +1475,7 @@ class SelectorDatagramTransportTests(unittest.TestCase):
self
.
assertTrue
(
transport
.
_fatal_error
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
asyncio_log
.exception'
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
logger
.exception'
)
def
test_fatal_error_connected
(
self
,
m_exc
):
transport
=
_SelectorDatagramTransport
(
self
.
loop
,
self
.
sock
,
self
.
protocol
,
(
'0.0.0.0'
,
1
))
...
...
Lib/test/test_asyncio/test_unix_events.py
View file @
fc29e0f3
...
...
@@ -87,7 +87,7 @@ class SelectorEventLoopTests(unittest.TestCase):
signal
.
SIGINT
,
lambda
:
True
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.signal'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
logger
'
)
def
test_add_signal_handler_install_error2
(
self
,
m_logging
,
m_signal
):
m_signal
.
NSIG
=
signal
.
NSIG
...
...
@@ -104,7 +104,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self
.
assertEqual
(
1
,
m_signal
.
set_wakeup_fd
.
call_count
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.signal'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
logger
'
)
def
test_add_signal_handler_install_error3
(
self
,
m_logging
,
m_signal
):
class
Err
(
OSError
):
errno
=
errno
.
EINVAL
...
...
@@ -149,7 +149,7 @@ class SelectorEventLoopTests(unittest.TestCase):
m_signal
.
signal
.
call_args
[
0
])
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.signal'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
logger
'
)
def
test_remove_signal_handler_cleanup_error
(
self
,
m_logging
,
m_signal
):
m_signal
.
NSIG
=
signal
.
NSIG
self
.
loop
.
add_signal_handler
(
signal
.
SIGHUP
,
lambda
:
True
)
...
...
@@ -270,7 +270,7 @@ class SelectorEventLoopTests(unittest.TestCase):
self
.
assertFalse
(
m_WEXITSTATUS
.
called
)
self
.
assertFalse
(
m_WTERMSIG
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
logger
'
)
@
unittest
.
mock
.
patch
(
'os.WTERMSIG'
)
@
unittest
.
mock
.
patch
(
'os.WEXITSTATUS'
)
@
unittest
.
mock
.
patch
(
'os.WIFSIGNALED'
)
...
...
@@ -360,7 +360,7 @@ class UnixReadPipeTransportTests(unittest.TestCase):
test_utils
.
run_briefly
(
self
.
loop
)
self
.
assertFalse
(
self
.
protocol
.
data_received
.
called
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
asyncio_log
.exception'
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
logger
.exception'
)
@
unittest
.
mock
.
patch
(
'os.read'
)
def
test__read_ready_error
(
self
,
m_read
,
m_logexc
):
tr
=
unix_events
.
_UnixReadPipeTransport
(
...
...
@@ -550,7 +550,7 @@ class UnixWritePipeTransportTests(unittest.TestCase):
self
.
loop
.
assert_writer
(
5
,
tr
.
_write_ready
)
self
.
assertEqual
([
b'data'
],
tr
.
_buffer
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
asyncio_log
'
)
@
unittest
.
mock
.
patch
(
'asyncio.unix_events.
logger
'
)
@
unittest
.
mock
.
patch
(
'os.write'
)
def
test_write_err
(
self
,
m_write
,
m_log
):
tr
=
unix_events
.
_UnixWritePipeTransport
(
...
...
@@ -648,7 +648,7 @@ class UnixWritePipeTransportTests(unittest.TestCase):
self
.
loop
.
assert_writer
(
5
,
tr
.
_write_ready
)
self
.
assertEqual
([
b'data'
],
tr
.
_buffer
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
asyncio_log
.exception'
)
@
unittest
.
mock
.
patch
(
'asyncio.log.
logger
.exception'
)
@
unittest
.
mock
.
patch
(
'os.write'
)
def
test__write_ready_err
(
self
,
m_write
,
m_logexc
):
tr
=
unix_events
.
_UnixWritePipeTransport
(
...
...
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