Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle warnings in tests #896

Merged
merged 6 commits into from
Mar 31, 2022
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
28 changes: 28 additions & 0 deletions ipykernel/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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())
6 changes: 6 additions & 0 deletions ipykernel/tests/test_embed_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 15 additions & 4 deletions ipykernel/tests/test_message_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion ipykernel/tests/test_pickleutil.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <socket.socket:ResourceWarning",
"ignore:unclosed event loop:ResourceWarning",
"ignore:There is no current event loop:DeprecationWarning"
]
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,20 @@ def run(self):
keywords=["Interactive", "Interpreter", "Shell", "Web"],
python_requires=">=3.7",
install_requires=[
"debugpy>=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",
Expand All @@ -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",
],
)

Expand Down