Commit a43e934a authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

TEST: notebook is difficult to kill

parent fb3f4934
......@@ -12,6 +12,7 @@ import glob
import shutil
import sys
import os
import signal
import os.path as op
import itertools as it
import subprocess as sp
......@@ -31,20 +32,29 @@ from . import tempdir
def test_demo():
def shutdown():
time.sleep(3)
with mock.patch('os.kill'):
for server in notebookapp.list_running_servers():
notebookapp.shutdown_server(server)
def nbfunc():
# add some extra args for running within docker
if op.exists('/.dockerenv'): args = ['--allow-root', '--ip=0.0.0.0']
else: args = None
mp.Process(target=shutdown).start()
with mock.patch('sys.argv', ['funpack_demo']):
ukbdemo.main(args)
# add some extra args for running within docker
if op.exists('/.dockerenv'): args = ['--allow-root', '--ip=0.0.0.0']
else: args = None
nbproc = mp.Process(target=nbfunc)
nbproc.start()
time.sleep(3)
with mock.patch('sys.argv', ['funpack_demo']):
ukbdemo.main(args)
servers = notebookapp.list_running_servers()
assert sum([s['pid'] == nbproc.pid for s in servers]) == 1
for s in servers:
if s['pid'] == nbproc.pid:
notebookapp.shutdown_server(s)
break
os.kill(nbproc.pid, signal.SIGKILL)
nbproc.join(0.5)
assert not nbproc.is_alive()
def test_demo_commands():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment