8000 bpo-34037: test_asyncio uses shutdown_default_executor() by vstinner · Pull Request #16284 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-34037: test_asyncio uses shutdown_default_executor() #16284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 19, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Simplify change
  • Loading branch information
vstinner committed Sep 19, 2019
commit 4cf7cd30aae0e194127eade88ecab08c07ddf30f
20 changes: 8 additions & 12 deletions Lib/test/test_asyncio/test_base_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,11 @@ class BaseEventLoopTests(test_utils.TestCase):
def setUp(self):
super().setUp()
self.loop = base_events.BaseEventLoop()
self.mock_event_loop(self.loop)
self.loop._selector = mock.Mock()
self.loop._selector.select.return_value = ()
self.set_event_loop(self.loop)

def mock_event_loop(self, loop):
loop._selector = mock.Mock()
loop._selector.select.return_value = ()
loop._process_events = mock.Mock()
loop._write_to_self = mock.Mock()

def test_not_implemented(self):
# setUp() calls mock_event_loop() which mocks _process_events
self.loop = base_events.BaseEventLoop()
self.set_event_loop(self.loop)

m = mock.Mock()
self.assertRaises(
NotImplementedError,
Expand Down Expand Up @@ -225,6 +216,9 @@ def submit(self, fn, *args, **kwargs):
raise NotImplementedError(
'cannot submit into a dummy executor')

self.loop._process_events = mock.Mock()
self.loop._write_to_self = mock.Mock()

executor = DummyExecutor()
self.loop.set_default_executor(executor)
self.assertIs(executor, self.loop._default_executor)
Expand All @@ -235,6 +229,9 @@ def test_set_default_executor_deprecation_warnings(self):
with self.assertWarns(DeprecationWarning):
self.loop.set_default_executor(executor)

# Avoid cleaning up the executor mock
self.loop._default_executor = None

def test_call_soon(self):
def cb():
pass
Expand Down Expand Up @@ -793,7 +790,6 @@ def create_task(self, coro):
return MyTask(coro, loop=loop)

loop = EventLoop()
self.mock_event_loop(loop)
self.set_event_loop(loop)

coro = test()
Expand Down
0