Skip to content

Commit

Permalink
Merge pull request #750 from blink1073/nose-cleanup
Browse files Browse the repository at this point in the history
Remove more nose test references
  • Loading branch information
Carreau authored Aug 24, 2021
2 parents db5f708 + cfc16db commit abefee4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 35 deletions.
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
17 changes: 9 additions & 8 deletions ipykernel/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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():
Expand Down
7 changes: 4 additions & 3 deletions ipykernel/tests/test_jsonutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)


Expand All @@ -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():
Expand Down
14 changes: 8 additions & 6 deletions ipykernel/tests/test_message_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down Expand Up @@ -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():
Expand Down
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
},
Expand Down

0 comments on commit abefee4

Please sign in to comment.