Skip to content

Commit eb5436e

Browse files
committed
Handle warnings
1 parent 7717f2c commit eb5436e

File tree

7 files changed

+54
-12
lines changed

7 files changed

+54
-12
lines changed

ipykernel/eventloops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import os
77
import platform
88
import sys
9-
from distutils.version import LooseVersion as V
9+
from pkg_resources import parse_version as V
1010
from functools import partial
1111

1212
import zmq

ipykernel/tests/conftest.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
try:
3+
import resource
4+
except ImportError:
5+
# Windows
6+
resource = None
7+
8+
9+
# Handle resource limit
10+
# Ensure a minimal soft limit of DEFAULT_SOFT if the current hard limit is at least that much.
11+
if resource is not None:
12+
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
13+
14+
DEFAULT_SOFT = 4096
15+
if hard >= DEFAULT_SOFT:
16+
soft = DEFAULT_SOFT
17+
18+
if hard < soft:
19+
hard = soft
20+
21+
resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard))

ipykernel/tests/test_embed_kernel.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ def connection_file_ready(connection_file):
7575
client.stop_channels()
7676
finally:
7777
kernel.terminate()
78+
kernel.wait()
79+
# Make sure all the fds get closed.
80+
for attr in ['stdout', 'stderr', 'stdin']:
81+
fid = getattr(kernel, attr)
82+
if fid:
83+
fid.close()
7884

7985

8086
@flaky(max_runs=3)

ipykernel/tests/test_message_spec.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
import re
77
import sys
8-
from distutils.version import LooseVersion as V
8+
from pkg_resources import parse_version as V
99
from queue import Empty
1010

1111
import jupyter_client
1212
import pytest
13-
from traitlets import Bool, Dict, Enum, HasTraits, Integer, List, TraitError, Unicode
13+
from traitlets import Bool, Dict, Enum, HasTraits, Integer, List, TraitError, Unicode, observe
1414

1515
from .utils import TIMEOUT, execute, flush_channels, get_reply, start_global_kernel
1616

@@ -98,8 +98,9 @@ class MimeBundle(Reference):
9898
metadata = Dict()
9999
data = Dict()
100100

101-
def _data_changed(self, name, old, new):
102-
for k, v in new.items():
101+
@observe('data')
102+
def _on_data_changed(self, change):
103+
for k, v in change['new'].items():
103104
assert mime_pat.match(k)
104105
assert isinstance(v, str)
105106

ipykernel/tests/test_pickleutil.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import pickle
2+
import warnings
23

3-
from ipykernel.pickleutil import can, uncan
4+
5+
with warnings.catch_warnings():
6+
warnings.simplefilter("ignore")
7+
from ipykernel.pickleutil import can, uncan
48

59

610
def interactive(f):

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,11 @@ testpaths = [
3737
timeout = 300
3838
# Restore this setting to debug failures
3939
# timeout_method = "thread"
40+
filterwarnings= [
41+
# Fail on warnings
42+
"error",
43+
44+
# Workarounds jupyter_client
45+
"ignore:unclosed <socket.socket:ResourceWarning",
46+
"ignore:unclosed event loop:ResourceWarning",
47+
]

setup.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,20 @@ def run(self):
6262
keywords=["Interactive", "Interpreter", "Shell", "Web"],
6363
python_requires=">=3.7",
6464
install_requires=[
65-
"debugpy>=1.0.0,<2.0",
65+
"debugpy>=1.0",
6666
"ipython>=7.23.1",
67-
"traitlets>=5.1.0,<6.0",
68-
"jupyter_client<8.0",
69-
"tornado>=5.0,<7.0",
70-
"matplotlib-inline>=0.1.0,<0.2.0",
67+
"traitlets>=5.1.0",
68+
"jupyter_client>=6.1.12",
69+
"tornado>=6.1",
70+
"matplotlib-inline>=0.1",
7171
'appnope;platform_system=="Darwin"',
7272
"psutil",
7373
"nest_asyncio",
74+
"setuptools>=60" # for pkg_resources
7475
],
7576
extras_require={
7677
"test": [
77-
"pytest !=5.3.4",
78+
"pytest>=6.0",
7879
"pytest-cov",
7980
"flaky",
8081
"ipyparallel",
@@ -92,6 +93,7 @@ def run(self):
9293
"Programming Language :: Python :: 3.7",
9394
"Programming Language :: Python :: 3.8",
9495
"Programming Language :: Python :: 3.9",
96+
"Programming Language :: Python :: 3.10",
9597
],
9698
)
9799

0 commit comments

Comments
 (0)