diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8de7da368..a6c216b46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: - name: Run the tests timeout-minutes: 10 run: | - cmd="python -m pytest -vv -raXxs" + cmd="python -m pytest -vv" $cmd || $cmd --lf test_miniumum_versions: @@ -152,7 +152,7 @@ jobs: uses: jupyterlab/maintainer-tools/.github/actions/install-minimums@v1 - name: Run the unit tests run: | - cmd="python -m pytest -vv -raXxs" + cmd="python -m pytest -vv -W default" $cmd || $cmd --lf test_prereleases: diff --git a/ipykernel/eventloops.py b/ipykernel/eventloops.py index 23f5f632b..6f486ace1 100644 --- a/ipykernel/eventloops.py +++ b/ipykernel/eventloops.py @@ -6,10 +6,10 @@ import os import platform import sys -from distutils.version import LooseVersion as V from functools import partial import zmq +from pkg_resources import parse_version as V from traitlets.config.application import Application diff --git a/ipykernel/tests/conftest.py b/ipykernel/tests/conftest.py new file mode 100644 index 000000000..a14511ef8 --- /dev/null +++ b/ipykernel/tests/conftest.py @@ -0,0 +1,28 @@ +import asyncio +import os + +try: + import resource +except ImportError: + # Windows + resource = None + + +# Handle resource limit +# Ensure a minimal soft limit of DEFAULT_SOFT if the current hard limit is at least that much. +if resource is not None: + soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE) + + DEFAULT_SOFT = 4096 + if hard >= DEFAULT_SOFT: + soft = DEFAULT_SOFT + + if hard < soft: + hard = soft + + resource.setrlimit(resource.RLIMIT_NOFILE, (soft, hard)) + + +# Enforce selector event loop on Windows. +if os.name == "nt": + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) diff --git a/ipykernel/tests/test_embed_kernel.py b/ipykernel/tests/test_embed_kernel.py index 81eb234de..2a9eaba98 100644 --- a/ipykernel/tests/test_embed_kernel.py +++ b/ipykernel/tests/test_embed_kernel.py @@ -75,6 +75,12 @@ def connection_file_ready(connection_file): client.stop_channels() finally: kernel.terminate() + kernel.wait() + # Make sure all the fds get closed. + for attr in ["stdout", "stderr", "stdin"]: + fid = getattr(kernel, attr) + if fid: + fid.close() @flaky(max_runs=3) diff --git a/ipykernel/tests/test_message_spec.py b/ipykernel/tests/test_message_spec.py index 94cf107f5..c5df456f8 100644 --- a/ipykernel/tests/test_message_spec.py +++ b/ipykernel/tests/test_message_spec.py @@ -5,12 +5,22 @@ import re import sys -from distutils.version import LooseVersion as V from queue import Empty import jupyter_client import pytest -from traitlets import Bool, Dict, Enum, HasTraits, Integer, List, TraitError, Unicode +from pkg_resources import parse_version as V +from traitlets import ( + Bool, + Dict, + Enum, + HasTraits, + Integer, + List, + TraitError, + Unicode, + observe, +) from .utils import TIMEOUT, execute, flush_channels, get_reply, start_global_kernel @@ -98,8 +108,9 @@ class MimeBundle(Reference): metadata = Dict() data = Dict() - def _data_changed(self, name, old, new): - for k, v in new.items(): + @observe("data") + def _on_data_changed(self, change): + for k, v in change["new"].items(): assert mime_pat.match(k) assert isinstance(v, str) diff --git a/ipykernel/tests/test_pickleutil.py b/ipykernel/tests/test_pickleutil.py index 1cba3cb99..c48eadf77 100644 --- a/ipykernel/tests/test_pickleutil.py +++ b/ipykernel/tests/test_pickleutil.py @@ -1,6 +1,9 @@ import pickle +import warnings -from ipykernel.pickleutil import can, uncan +with warnings.catch_warnings(): + warnings.simplefilter("ignore") + from ipykernel.pickleutil import can, uncan def interactive(f): diff --git a/pyproject.toml b/pyproject.toml index 2efcc10fc..ed605e2ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,3 +37,12 @@ testpaths = [ timeout = 300 # Restore this setting to debug failures # timeout_method = "thread" +filterwarnings= [ + # Fail on warnings + "error", + + # Ignore jupyter_client warnings + "ignore:unclosed =1.0.0,<2.0", + "debugpy>=1.0", "ipython>=7.23.1", - "traitlets>=5.1.0,<6.0", - "jupyter_client<8.0", - "tornado>=5.0,<7.0", - "matplotlib-inline>=0.1.0,<0.2.0", + "traitlets>=5.1.0", + "jupyter_client>=6.1.12", + "tornado>=6.1", + "matplotlib-inline>=0.1", 'appnope;platform_system=="Darwin"', "psutil", "nest_asyncio", + "setuptools>=60", # for pkg_resources ], extras_require={ "test": [ - "pytest !=5.3.4", + "pytest>=6.0", "pytest-cov", "flaky", "ipyparallel", @@ -92,6 +93,7 @@ def run(self): "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", ], )