Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def _input_request(self, prompt, ident, parent, password=False):
except KeyboardInterrupt:
# re-raise KeyboardInterrupt, to truncate traceback
raise KeyboardInterrupt("Interrupted by user") from None
except Exception as e:
except Exception:
self.log.warning("Invalid Message:", exc_info=True)

try:
Expand Down
14 changes: 7 additions & 7 deletions ipykernel/tests/test_embed_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ def test_embed_kernel_basic():

with setup_kernel(cmd) as client:
# oinfo a (int)
msg_id = client.inspect('a')
client.inspect("a")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']

msg_id = client.execute("c=a*2")
client.execute("c=a*2")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['status'] == 'ok'

# oinfo c (should be 10)
msg_id = client.inspect('c')
client.inspect("c")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
Expand All @@ -128,23 +128,23 @@ def test_embed_kernel_namespace():

with setup_kernel(cmd) as client:
# oinfo a (int)
msg_id = client.inspect('a')
client.inspect("a")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert '5' in text

# oinfo b (str)
msg_id = client.inspect('b')
client.inspect("b")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert 'hi there' in text

# oinfo c (undefined)
msg_id = client.inspect('c')
client.inspect("c")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert not content['found']
Expand All @@ -167,7 +167,7 @@ def test_embed_kernel_reentrant():

with setup_kernel(cmd) as client:
for i in range(5):
msg_id = client.inspect('count')
client.inspect("count")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/tests/test_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def test_control_thread_priority():
control_msg_ids.append(msg["header"]["msg_id"])

# finally, collect the replies on both channels for comparison
sleep_reply = get_reply(kc, sleep_msg_id)
get_reply(kc, sleep_msg_id)
shell_replies = []
for msg_id in shell_msg_ids:
shell_replies.append(get_reply(kc, msg_id))
Expand Down
7 changes: 3 additions & 4 deletions ipykernel/tests/test_kernelspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ def test_write_kernel_spec_path():
def test_install_kernelspec():

path = tempfile.mkdtemp()
try:
test = InstallIPythonKernelSpecApp.launch_instance(argv=['--prefix', path])
assert_is_spec(os.path.join(
path, 'share', 'jupyter', 'kernels', KERNEL_NAME))
try:
InstallIPythonKernelSpecApp.launch_instance(argv=["--prefix", path])
assert_is_spec(os.path.join(path, "share", "jupyter", "kernels", KERNEL_NAME))
finally:
shutil.rmtree(path)

Expand Down
27 changes: 14 additions & 13 deletions ipykernel/tests/test_message_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,15 @@ def test_execute_inc():
"""execute request should increment execution_count"""
flush_channels()

msg_id, reply = execute(code='x=1')
count = reply['execution_count']
_, reply = execute(code="x=1")
count = reply["execution_count"]

flush_channels()

msg_id, reply = execute(code='x=2')
count_2 = reply['execution_count']
assert count_2 == count+1
_, reply = execute(code="x=2")
count_2 = reply["execution_count"]
assert count_2 == count + 1


def test_execute_stop_on_error():
"""execute request should not abort execution queue with stop_on_error False"""
Expand All @@ -342,15 +343,15 @@ def test_execute_stop_on_error():
'raise ValueError',
])
KC.execute(code=fail)
msg_id = KC.execute(code='print("Hello")')
KC.execute(code='print("Hello")')
KC.get_shell_msg(timeout=TIMEOUT)
reply = KC.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'aborted'

flush_channels()

KC.execute(code=fail, stop_on_error=False)
msg_id = KC.execute(code='print("Hello")')
KC.execute(code='print("Hello")')
KC.get_shell_msg(timeout=TIMEOUT)
reply = KC.get_shell_msg(timeout=TIMEOUT)
assert reply['content']['status'] == 'ok'
Expand Down Expand Up @@ -519,8 +520,8 @@ def test_is_complete():
def test_history_range():
flush_channels()

msg_id_exec = KC.execute(code='x=1', store_history = True)
reply_exec = KC.get_shell_msg(timeout=TIMEOUT)
KC.execute(code="x=1", store_history=True)
KC.get_shell_msg(timeout=TIMEOUT)

msg_id = KC.history(hist_access_type = 'range', raw = True, output = True, start = 1, stop = 2, session = 0)
reply = get_reply(KC, msg_id, TIMEOUT)
Expand All @@ -531,8 +532,8 @@ def test_history_range():
def test_history_tail():
flush_channels()

msg_id_exec = KC.execute(code='x=1', store_history = True)
reply_exec = KC.get_shell_msg(timeout=TIMEOUT)
KC.execute(code="x=1", store_history=True)
KC.get_shell_msg(timeout=TIMEOUT)

msg_id = KC.history(hist_access_type = 'tail', raw = True, output = True, n = 1, session = 0)
reply = get_reply(KC, msg_id, TIMEOUT)
Expand All @@ -543,8 +544,8 @@ def test_history_tail():
def test_history_search():
flush_channels()

msg_id_exec = KC.execute(code='x=1', store_history = True)
reply_exec = KC.get_shell_msg(timeout=TIMEOUT)
KC.execute(code="x=1", store_history=True)
KC.get_shell_msg(timeout=TIMEOUT)

msg_id = KC.history(hist_access_type = 'search', raw = True, output = True, n = 1, pattern = '*', session = 0)
reply = get_reply(KC, msg_id, TIMEOUT)
Expand Down
18 changes: 9 additions & 9 deletions ipykernel/tests/test_start_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ def test_ipython_start_kernel_userns():
'start_kernel(user_ns=ns)')

with setup_kernel(cmd) as client:
msg_id = client.inspect('tre')
client.inspect("tre")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
text = content['data']['text/plain']
assert '123' in text

# user_module should be an instance of DummyMod
msg_id = client.execute("usermod = get_ipython().user_module")
client.execute("usermod = get_ipython().user_module")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['status'] == 'ok'
msg_id = client.inspect('usermod')
content = msg["content"]
assert content["status"] == "ok"
client.inspect("usermod")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
Expand All @@ -39,11 +39,11 @@ def test_ipython_start_kernel_no_userns():

with setup_kernel(cmd) as client:
# user_module should not be an instance of DummyMod
msg_id = client.execute("usermod = get_ipython().user_module")
client.execute("usermod = get_ipython().user_module")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['status'] == 'ok'
msg_id = client.inspect('usermod')
content = msg["content"]
assert content["status"] == "ok"
client.inspect("usermod")
msg = client.get_shell_msg(block=True, timeout=TIMEOUT)
content = msg['content']
assert content['found']
Expand Down