File tree Expand file tree Collapse file tree 3 files changed +42
-2
lines changed
Expand file tree Collapse file tree 3 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ def encode_images(format_dict):
7474 return format_dict
7575
7676
77- def json_clean (obj ):
77+ def json_clean (obj ): # pragma: no cover
7878 """Deprecated, this is a no-op for jupyter-client>=7.
7979
8080 Clean an object to ensure it's safe to encode in JSON.
Original file line number Diff line number Diff line change 1+ import os
2+ import sys
3+ import warnings
4+ from unittest import mock
5+
6+ import pytest
7+
8+ from ipykernel .parentpoller import ParentPollerUnix , ParentPollerWindows
9+
10+
11+ @pytest .mark .skipif (os .name == "nt" , reason = "only works on posix" )
12+ def test_parent_poller_unix ():
13+ poller = ParentPollerUnix ()
14+ with mock .patch ("os.getppid" , lambda : 1 ):
15+
16+ def exit_mock (* args ):
17+ sys .exit (1 )
18+
19+ with mock .patch ("os._exit" , exit_mock ), pytest .raises (SystemExit ):
20+ poller .run ()
21+
22+ def mock_getppid ():
23+ raise ValueError ("hi" )
24+
25+ with mock .patch ("os.getppid" , mock_getppid ), pytest .raises (ValueError ):
26+ poller .run ()
27+
28+
29+ @pytest .mark .skipif (os .name != "nt" , reason = "only works on windows" )
30+ def test_parent_poller_windows ():
31+ poller = ParentPollerWindows (interrupt_handle = 1 )
32+
33+ def mock_wait (* args , ** kwargs ):
34+ return - 1
35+
36+ with mock .patch ("ctypes.windll.kernel32.WaitForMultipleObjects" , mock_wait ):
37+ with warnings .catch_warnings ():
38+ warnings .simplefilter ("ignore" )
39+ poller .run ()
Original file line number Diff line number Diff line change @@ -157,7 +157,8 @@ omit = [
157157 " ipykernel/tests/*" ,
158158 " ipykernel/debugger.py" ,
159159 " ipykernel/eventloops.py" ,
160- " ipykernel/pickleutil.py"
160+ " ipykernel/pickleutil.py" ,
161+ " ipykernel/serialize.py"
161162]
162163
163164[tool .flake8 ]
You can’t perform that action at this time.
0 commit comments