From cfc16dbf7053874bcc24a25228d0d0529d340a13 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 24 Aug 2021 05:50:53 -0500 Subject: [PATCH] Remove more nose test references --- README.md | 18 +++++------------- ipykernel/tests/test_io.py | 17 +++++++++-------- ipykernel/tests/test_jsonutil.py | 7 ++++--- ipykernel/tests/test_message_spec.py | 14 ++++++++------ setup.cfg | 4 ---- setup.py | 2 +- 6 files changed, 27 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 9744da286..06574280f 100644 --- a/README.md +++ b/README.md @@ -6,34 +6,26 @@ This package provides the IPython kernel for Jupyter. 1. `git clone` 2. `cd ipykernel` -3. `pip install -e .` +3. `pip install -e ".[test]"` After that, all normal `ipython` commands will use this newly-installed version of the kernel. ## Running tests -Ensure you have `nosetests` and the `nose-warnings-filters` plugin installed with - -```bash -pip install nose nose-warnings-filters -``` +Follow the instructions from `Installation from source`. and then from the root directory ```bash -nosetests ipykernel +pytest ipykernel ``` ## Running tests with coverage -Follow the instructions from `Running tests`. Ensure you have the `coverage` module installed with - -```bash -pip install coverage -``` +Follow the instructions from `Installation from source`. and then from the root directory ```bash -nosetests --with-coverage --cover-package ipykernel ipykernel +pytest ipykernel -vv -s --cov ipykernel --cov-branch --cov-report term-missing:skip-covered --durations 10 ``` diff --git a/ipykernel/tests/test_io.py b/ipykernel/tests/test_io.py index 9fe3f4e2e..cad617879 100644 --- a/ipykernel/tests/test_io.py +++ b/ipykernel/tests/test_io.py @@ -4,10 +4,11 @@ import zmq +import pytest + from jupyter_client.session import Session from ipykernel.iostream import IOPubThread, OutStream -import nose.tools as nt def test_io_api(): """Test that wrapped stdout has the same API as a normal TextIO object""" @@ -26,19 +27,19 @@ def test_io_api(): assert stream.errors is None assert not stream.isatty() - with nt.assert_raises(io.UnsupportedOperation): + with pytest.raises(io.UnsupportedOperation): stream.detach() - with nt.assert_raises(io.UnsupportedOperation): + with pytest.raises(io.UnsupportedOperation): next(stream) - with nt.assert_raises(io.UnsupportedOperation): + with pytest.raises(io.UnsupportedOperation): stream.read() - with nt.assert_raises(io.UnsupportedOperation): + with pytest.raises(io.UnsupportedOperation): stream.readline() - with nt.assert_raises(io.UnsupportedOperation): + with pytest.raises(io.UnsupportedOperation): stream.seek(0) - with nt.assert_raises(io.UnsupportedOperation): + with pytest.raises(io.UnsupportedOperation): stream.tell() - with nt.assert_raises(TypeError): + with pytest.raises(TypeError): stream.write(b'') def test_io_isatty(): diff --git a/ipykernel/tests/test_jsonutil.py b/ipykernel/tests/test_jsonutil.py index 4d8ccb604..9e9f0e5e3 100644 --- a/ipykernel/tests/test_jsonutil.py +++ b/ipykernel/tests/test_jsonutil.py @@ -9,7 +9,7 @@ from datetime import datetime import numbers -import nose.tools as nt +import pytest from .. import jsonutil from ..jsonutil import json_clean, encode_images @@ -84,7 +84,7 @@ def test_encode_images(): assert decoded == value def test_lambda(): - with nt.assert_raises(ValueError): + with pytest.raises(ValueError): json_clean(lambda : 1) @@ -93,7 +93,8 @@ def test_exception(): {True:'bool', 'True':'string'}, ] for d in bad_dicts: - nt.assert_raises(ValueError, json_clean, d) + with pytest.raises(ValueError): + json_clean(d) def test_unicode_dict(): diff --git a/ipykernel/tests/test_message_spec.py b/ipykernel/tests/test_message_spec.py index bfa81ca96..40ec5e4e2 100644 --- a/ipykernel/tests/test_message_spec.py +++ b/ipykernel/tests/test_message_spec.py @@ -8,8 +8,6 @@ from distutils.version import LooseVersion as V from queue import Empty -import nose.tools as nt - import pytest import jupyter_client @@ -295,7 +293,9 @@ def test_execute_silent(): validate_message(status, 'status', msg_id) assert status['content']['execution_state'] == 'idle' - nt.assert_raises(Empty, KC.get_iopub_msg, timeout=0.1) + with pytest.raises(Empty): + KC.get_iopub_msg(timeout=0.1) + count = reply['execution_count'] msg_id, reply = execute(code='x=2', silent=True) @@ -305,7 +305,9 @@ def test_execute_silent(): validate_message(status, 'status', msg_id) assert status['content']['execution_state'] == 'idle' - nt.assert_raises(Empty, KC.get_iopub_msg, timeout=0.1) + with pytest.raises(Empty): + KC.get_iopub_msg(timeout=0.1) + count_2 = reply['execution_count'] assert count_2 == count @@ -389,11 +391,11 @@ def test_user_expressions(): msg_id, reply = execute(code='x=1', user_expressions=dict(foo='x+1')) user_expressions = reply['user_expressions'] - nt.assert_equal(user_expressions, {'foo': { + assert user_expressions == {'foo': { 'status': 'ok', 'data': {'text/plain': '2'}, 'metadata': {}, - }}) + }} def test_user_expressions_fail(): diff --git a/setup.cfg b/setup.cfg index 7fd8e1ae1..065b8a89c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,10 +6,6 @@ universal=0 license_file = COPYING.md version = attr: ipykernel._version.__version__ -[nosetests] -warningfilters= default |.* |DeprecationWarning |ipykernel.* - error |.*invalid.* |DeprecationWarning |matplotlib.* - [flake8] # References: # https://flake8.readthedocs.io/en/latest/user/configuration.html diff --git a/setup.py b/setup.py index 8517cd99f..4d14627aa 100644 --- a/setup.py +++ b/setup.py @@ -77,7 +77,7 @@ def run(self): "pytest !=5.3.4", "pytest-cov", "flaky", - "nose", # nose because there are still a few nose.tools imports hanging around + "nose", # nose because we are still using nose streams from ipython "ipyparallel", ], },