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
33cb0396
Commit
33cb0396
authored
Jan 15, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #23243: Close explicitly event loops in asyncio tests
parent
41ed958e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
1 deletion
+20
-1
Lib/test/test_asyncio/test_base_events.py
Lib/test/test_asyncio/test_base_events.py
+1
-0
Lib/test/test_asyncio/test_proactor_events.py
Lib/test/test_asyncio/test_proactor_events.py
+4
-0
Lib/test/test_asyncio/test_selector_events.py
Lib/test/test_asyncio/test_selector_events.py
+15
-1
No files found.
Lib/test/test_asyncio/test_base_events.py
View file @
33cb0396
...
...
@@ -590,6 +590,7 @@ class BaseEventLoopTests(test_utils.TestCase):
raise
ValueError
(
'spam'
)
loop
=
Loop
()
self
.
addCleanup
(
loop
.
close
)
asyncio
.
set_event_loop
(
loop
)
def
run_loop
():
...
...
Lib/test/test_asyncio/test_proactor_events.py
View file @
33cb0396
...
...
@@ -16,6 +16,7 @@ class ProactorSocketTransportTests(test_utils.TestCase):
def
setUp
(
self
):
self
.
loop
=
self
.
new_test_loop
()
self
.
addCleanup
(
self
.
loop
.
close
)
self
.
proactor
=
mock
.
Mock
()
self
.
loop
.
_proactor
=
self
.
proactor
self
.
protocol
=
test_utils
.
make_test_protocol
(
asyncio
.
Protocol
)
...
...
@@ -459,6 +460,9 @@ class BaseProactorEventLoopTests(test_utils.TestCase):
self
.
assertIsNone
(
self
.
loop
.
_ssock
)
self
.
assertIsNone
(
self
.
loop
.
_csock
)
# Don't call close(): _close_self_pipe() cannot be called twice
self
.
loop
.
_closed
=
True
def
test_close
(
self
):
self
.
loop
.
_close_self_pipe
=
mock
.
Mock
()
self
.
loop
.
close
()
...
...
Lib/test/test_asyncio/test_selector_events.py
View file @
33cb0396
...
...
@@ -24,6 +24,11 @@ MOCK_ANY = mock.ANY
class
TestBaseSelectorEventLoop
(
BaseSelectorEventLoop
):
def
close
(
self
):
# Don't call the close() method of the parent class, because the
# selector is mocked
self
.
_closed
=
True
def
_make_self_pipe
(
self
):
self
.
_ssock
=
mock
.
Mock
()
self
.
_csock
=
mock
.
Mock
()
...
...
@@ -40,7 +45,7 @@ class BaseSelectorEventLoopTests(test_utils.TestCase):
self
.
selector
=
mock
.
Mock
()
self
.
selector
.
select
.
return_value
=
[]
self
.
loop
=
TestBaseSelectorEventLoop
(
self
.
selector
)
self
.
set_event_loop
(
self
.
loop
,
cleanup
=
False
)
self
.
set_event_loop
(
self
.
loop
)
def
test_make_socket_transport
(
self
):
m
=
mock
.
Mock
()
...
...
@@ -76,6 +81,15 @@ class BaseSelectorEventLoopTests(test_utils.TestCase):
self
.
loop
.
_make_ssl_transport
(
m
,
m
,
m
,
m
)
def
test_close
(
self
):
class
EventLoop
(
BaseSelectorEventLoop
):
def
_make_self_pipe
(
self
):
self
.
_ssock
=
mock
.
Mock
()
self
.
_csock
=
mock
.
Mock
()
self
.
_internal_fds
+=
1
self
.
loop
=
EventLoop
(
self
.
selector
)
self
.
set_event_loop
(
self
.
loop
)
ssock
=
self
.
loop
.
_ssock
ssock
.
fileno
.
return_value
=
7
csock
=
self
.
loop
.
_csock
...
...
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