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
ffcb4c01
Commit
ffcb4c01
authored
Dec 30, 2017
by
Andrew Svetlov
Committed by
GitHub
Dec 30, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-32418: Postfix, raise NotImplementdError and close resources in tests (#5052)
parent
1634fc28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
5 deletions
+22
-5
Lib/asyncio/events.py
Lib/asyncio/events.py
+3
-3
Lib/test/test_asyncio/test_events.py
Lib/test/test_asyncio/test_events.py
+19
-2
No files found.
Lib/asyncio/events.py
View file @
ffcb4c01
...
@@ -149,15 +149,15 @@ class AbstractServer:
...
@@ -149,15 +149,15 @@ class AbstractServer:
def
close
(
self
):
def
close
(
self
):
"""Stop serving. This leaves existing connections open."""
"""Stop serving. This leaves existing connections open."""
r
eturn
NotImplemented
r
aise
NotImplementedError
async
def
wait_closed
(
self
):
async
def
wait_closed
(
self
):
"""Coroutine to wait until service is closed."""
"""Coroutine to wait until service is closed."""
r
eturn
NotImplemented
r
aise
NotImplementedError
def
get_loop
(
self
):
def
get_loop
(
self
):
""" Get the event loop the Server object is attached to."""
""" Get the event loop the Server object is attached to."""
r
eturn
NotImplemented
r
aise
NotImplementedError
class
AbstractEventLoop
:
class
AbstractEventLoop
:
...
...
Lib/test/test_asyncio/test_events.py
View file @
ffcb4c01
...
@@ -2826,19 +2826,36 @@ else:
...
@@ -2826,19 +2826,36 @@ else:
get_running_loop_impl
=
events
.
_c_get_running_loop
get_running_loop_impl
=
events
.
_c_get_running_loop
get_event_loop_impl
=
events
.
_c_get_event_loop
get_event_loop_impl
=
events
.
_c_get_event_loop
class
TestServer
(
unittest
.
TestCase
):
class
TestServer
(
unittest
.
TestCase
):
def
test_get_loop
(
self
):
def
test_get_loop
(
self
):
loop
=
asyncio
.
new_event_loop
()
loop
=
asyncio
.
new_event_loop
()
self
.
addCleanup
(
loop
.
close
)
proto
=
MyProto
(
loop
)
proto
=
MyProto
(
loop
)
server
=
loop
.
run_until_complete
(
loop
.
create_server
(
lambda
:
proto
,
'0.0.0.0'
,
0
))
server
=
loop
.
run_until_complete
(
loop
.
create_server
(
lambda
:
proto
,
'0.0.0.0'
,
0
))
self
.
assertEqual
(
server
.
get_loop
(),
loop
)
self
.
assertEqual
(
server
.
get_loop
(),
loop
)
loop
.
close
()
server
.
close
()
loop
.
run_until_complete
(
server
.
wait_closed
())
class
TestAbstractServer
(
unittest
.
TestCase
):
class
TestAbstractServer
(
unittest
.
TestCase
):
def
test_close
(
self
):
with
self
.
assertRaises
(
NotImplementedError
):
events
.
AbstractServer
().
close
()
def
test_wait_closed
(
self
):
loop
=
asyncio
.
new_event_loop
()
self
.
addCleanup
(
loop
.
close
)
with
self
.
assertRaises
(
NotImplementedError
):
loop
.
run_until_complete
(
events
.
AbstractServer
().
wait_closed
())
def
test_get_loop
(
self
):
def
test_get_loop
(
self
):
self
.
assertEqual
(
events
.
AbstractServer
().
get_loop
(),
NotImplemented
)
with
self
.
assertRaises
(
NotImplementedError
):
events
.
AbstractServer
().
get_loop
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
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