Skip to content

Commit

Permalink
Merge pull request #646 from kevin-bates/fix-tests
Browse files Browse the repository at this point in the history
Update test kernel with native coroutine, remove async_generator dependency
  • Loading branch information
davidbrochart authored Apr 28, 2021
2 parents 3515e89 + 3b85485 commit 98faaf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
6 changes: 2 additions & 4 deletions jupyter_client/tests/signalkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ipykernel.displayhook import ZMQDisplayHook
from ipykernel.kernelapp import IPKernelApp
from ipykernel.kernelbase import Kernel
from tornado.web import gen


class SignalTestKernel(Kernel):
Expand All @@ -28,10 +27,9 @@ def __init__(self, **kwargs):
if os.environ.get("NO_SIGTERM_REPLY", None) == "1":
signal.signal(signal.SIGTERM, signal.SIG_IGN)

@gen.coroutine
def shutdown_request(self, stream, ident, parent):
async def shutdown_request(self, stream, ident, parent):
if os.environ.get("NO_SHUTDOWN_REPLY") != "1":
yield gen.maybe_future(super().shutdown_request(stream, ident, parent))
await super().shutdown_request(stream, ident, parent)

def do_execute(
self, code, silent, store_history=True, user_expressions=None, allow_stdin=False
Expand Down
12 changes: 7 additions & 5 deletions jupyter_client/tests/test_kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from subprocess import PIPE

import pytest
from async_generator import async_generator
from async_generator import yield_
from jupyter_core import paths
from traitlets.config.loader import Config

Expand Down Expand Up @@ -135,11 +133,9 @@ def async_km_subclass(config):


@pytest.fixture
@async_generator # This is only necessary while Python 3.5 is support afterwhich both it and
# yield_() can be removed
async def start_async_kernel():
km, kc = await start_new_async_kernel(kernel_name="signaltest")
await yield_((km, kc))
yield km, kc
kc.stop_channels()
await km.shutdown_kernel()
assert km.context.closed
Expand All @@ -166,6 +162,9 @@ class TestKernelManagerShutDownGracefully:
@pytest.mark.skipif(sys.platform == "win32", reason="Windows doesn't support signals")
@pytest.mark.parametrize(*parameters)
def test_signal_kernel_subprocesses(self, name, install, expected):
# ipykernel doesn't support 3.6 and this test uses async shutdown_request
if expected == _ShutdownStatus.ShutdownRequest and sys.version_info < (3, 7):
pytest.skip()
install()
km, kc = start_new_kernel(kernel_name=name)
assert km._shutdown_status == _ShutdownStatus.Unset
Expand All @@ -180,6 +179,9 @@ def test_signal_kernel_subprocesses(self, name, install, expected):
@pytest.mark.skipif(sys.platform == "win32", reason="Windows doesn't support signals")
@pytest.mark.parametrize(*parameters)
async def test_async_signal_kernel_subprocesses(self, name, install, expected):
# ipykernel doesn't support 3.6 and this test uses async shutdown_request
if expected == _ShutdownStatus.ShutdownRequest and sys.version_info < (3, 7):
pytest.skip()
install()
km, kc = await start_new_async_kernel(kernel_name=name)
assert km._shutdown_status == _ShutdownStatus.Unset
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def run(self):
python_requires='>=3.6.1',
extras_require={
'test': [
'async_generator',
'ipykernel',
'ipython',
'jedi<0.18; python_version<="3.6"',
Expand Down

0 comments on commit 98faaf9

Please sign in to comment.