Repository: 0rpc/zerorpc-python (language: python)

Issue:
0.6.3: test suite is using `nose` module
`nose` is no longer maintained and should not be used with python 3.x.
https://nose.readthedocs.io/en/latest/

On move from `nose` to `pytest` https://github.com/schollii/nose2pytest/


Discussion / hints:
Looks like it was easy to migrate so I've done that.
Result:
```console
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-zerorpc-0.6.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-zerorpc-0.6.3-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -p no:relaxed --ignore tests/test_client_async.py --deselect tests/test_server.py::test_exception_compat_v1
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3
plugins: nose2pytest-1.0.8
collected 78 items / 1 deselected / 77 selected

tests/test_buffered_channel.py ..........                                                                                                                            [ 12%]
tests/test_channel.py ...                                                                                                                                            [ 16%]
tests/test_client.py ..                                                                                                                                              [ 19%]
tests/test_client_heartbeat.py ......                                                                                                                                [ 27%]
tests/test_events.py .......                                                                                                                                         [ 36%]
tests/test_heartbeat.py ........                                                                                                                                     [ 46%]
tests/test_middleware.py ..........                                                                                                                                  [ 59%]
tests/test_middleware_before_after_exec.py .........                                                                                                                 [ 71%]
tests/test_middleware_client.py ..........                                                                                                                           [ 84%]
tests/test_pubpush.py ....                                                                                                                                           [ 89%]
tests/test_reqstream.py .                                                                                                                                            [ 90%]
tests/test_server.py ......                                                                                                                                          [ 98%]
tests/test_zmq.py .                                                                                                                                                  [100%]

============================================================================= warnings summary =============================================================================
tests/test_reqstream.py::test_rcp_streaming
  /home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/tests/test_reqstream.py:61: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
    assert isinstance(r, collections.Iterator)

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=============================================================== 77 passed, 1 deselected, 1 warning in 29.22s ===============================================================
```
Here is the patch:
```patch
--- a/setup.py  2019-06-26 10:00:19.000000000 +0100
+++ b/setup.py  2021-12-21 17:53:43.738370582 +0000
@@ -64,8 +64,8 @@
     url='https://github.com/0rpc/zerorpc-python',
     packages=['zerorpc'],
     install_requires=requirements,
-    tests_require=['nose'],
-    test_suite='nose.collector',
+    tests_require=['pytest'],
+    test_suite='pytest.collector',
     zip_safe=False,
     entry_points={'console_scripts': ['zerorpc = zerorpc.cli:main']},
     license='MIT',
--- a/tests/test_buffered_channel.py    2019-06-26 10:00:19.000000000 +0100
+++ b/tests/test_buffered_channel.py    2021-12-21 18:36:12.163644052 +0000
@@ -27,7 +27,7 @@
 from __future__ import absolute_import
 from builtins import range

-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys

@@ -61,9 +61,9 @@
     print('CLOSE SERVER SOCKET!!!')
     server_bufchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_bufchan.recv()
     print('CLIENT LOST SERVER :)')
     client_bufchan.close()
@@ -96,9 +96,9 @@
     print('CLOSE CLIENT SOCKET!!!')
     client_bufchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_bufchan.recv()
     print('SERVER LOST CLIENT :)')
     server_bufchan.close()
@@ -129,9 +129,9 @@
     print('CLOSE SERVER SOCKET!!!')
     server_bufchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_bufchan.recv()
     print('CLIENT LOST SERVER :)')
     client_bufchan.close()
@@ -170,9 +170,9 @@
     client_bufchan.close()
     client.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, server_coro.get)
+        pytest.raises(zerorpc.LostRemote, server_coro.get)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             server_coro.get()
     print('SERVER LOST CLIENT :)')
     server.close()
@@ -244,9 +244,9 @@
             assert list(event.args) == [x + x * x]
         client_bufchan.emit('add', (x, x * x))
         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+            pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 client_bufchan.recv()
         client_bufchan.close()

@@ -308,9 +308,9 @@
             server_bufchan.emit('OK', (sum(event.args),))

         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, server_bufchan.recv)
+            pytest.raises(zerorpc.LostRemote, server_bufchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 server_bufchan.recv()
         server_bufchan.close()

@@ -343,9 +343,9 @@
                     event = client_bufchan.recv(timeout=TIME_FACTOR * 3)
                     assert event.name == 'OK'
                     assert list(event.args) == [x]
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(10):
                     client_bufchan.emit('sleep', (x,))
                     event = client_bufchan.recv(timeout=TIME_FACTOR * 3)
@@ -369,9 +369,9 @@
                     assert event.name == 'sleep'
                     gevent.sleep(TIME_FACTOR * event.args[0])
                     server_bufchan.emit('OK', event.args)
-            assert_raises(zerorpc.LostRemote, _do_with_assert_raises)
+            pytest.raises(zerorpc.LostRemote, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 for x in range(20):
                     event = server_bufchan.recv()
                     assert event.name == 'sleep'
@@ -422,9 +422,9 @@
             def _do_with_assert_raises():
                 for x in range(200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 1
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 1
         server_bufchan.emit('coucou', 1)  # block until receiver is ready
@@ -432,9 +432,9 @@
             def _do_with_assert_raises():
                 for x in range(2, 200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 100
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(2, 200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 100
         for x in range(read_cnt.value, 200):
--- a/tests/test_client_async.py        2019-06-26 10:00:19.000000000 +0100
+++ b/tests/test_client_async.py        2021-12-21 18:34:33.983863012 +0000
@@ -25,7 +25,7 @@

 from __future__ import print_function
 from __future__ import absolute_import
-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys

@@ -58,9 +58,9 @@
     if sys.version_info < (2, 7):
         def _do_with_assert_raises():
             print(async_result.get())
-        assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+        pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
     else:
-        with assert_raises(zerorpc.TimeoutExpired):
+        with pytest.raises(zerorpc.TimeoutExpired):
             print(async_result.get())
     client.close()
     srv.close()
--- a/tests/test_heartbeat.py   2019-06-26 10:00:19.000000000 +0100
+++ b/tests/test_heartbeat.py   2021-12-21 18:30:10.115763883 +0000
@@ -27,7 +27,7 @@
 from __future__ import absolute_import
 from builtins import range

-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys

@@ -59,9 +59,9 @@
     print('CLOSE SERVER SOCKET!!!')
     server_hbchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_hbchan.recv()
     print('CLIENT LOST SERVER :)')
     client_hbchan.close()
@@ -92,9 +92,9 @@
     print('CLOSE CLIENT SOCKET!!!')
     client_hbchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, server_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             server_hbchan.recv()
     print('SERVER LOST CLIENT :)')
     server_hbchan.close()
@@ -123,9 +123,9 @@
     print('CLOSE SERVER SOCKET!!!')
     server_hbchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_hbchan.recv()
     print('CLIENT LOST SERVER :)')
     client_hbchan.close()
@@ -155,9 +155,9 @@
     client_hbchan.close()
     client.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, server_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             server_hbchan.recv()
     print('SERVER LOST CLIENT :)')
     server_hbchan.close()
@@ -227,9 +227,9 @@
             assert list(event.args) == [x + x * x]
         client_hbchan.emit('add', (x, x * x))
         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, client_hbchan.recv)
+            pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 client_hbchan.recv()
         client_hbchan.close()

@@ -287,9 +287,9 @@
             server_hbchan.emit('OK', (sum(event.args),))

         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, server_hbchan.recv)
+            pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 server_hbchan.recv()
         server_hbchan.close()

@@ -322,9 +322,9 @@
                     event = client_hbchan.recv(timeout=TIME_FACTOR * 3)
                     assert event.name == 'OK'
                     assert list(event.args) == [x]
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(10):
                     client_hbchan.emit('sleep', (x,))
                     event = client_hbchan.recv(timeout=TIME_FACTOR * 3)
@@ -346,9 +346,9 @@
                     assert event.name == 'sleep'
                     gevent.sleep(TIME_FACTOR * event.args[0])
                     server_hbchan.emit('OK', event.args)
-            assert_raises(zerorpc.LostRemote, _do_with_assert_raises)
+            pytest.raises(zerorpc.LostRemote, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 for x in range(20):
                     event = server_hbchan.recv()
                     assert event.name == 'sleep'
--- a/tests/test_middleware.py  2019-06-26 10:00:19.000000000 +0100
+++ b/tests/test_middleware.py  2021-12-21 18:32:15.475761150 +0000
@@ -28,7 +28,7 @@
 from builtins import str
 from future.utils import tobytes

-from nose.tools import assert_raises
+import pytest
 import gevent
 import gevent.local
 import random
@@ -101,9 +101,9 @@

     srv = Srv(heartbeat=TIME_FACTOR * 1, context=c)
     if sys.version_info < (2, 7):
-        assert_raises(zmq.ZMQError, srv.bind, 'some_service')
+        pytest.raises(zmq.ZMQError, srv.bind, 'some_service')
     else:
-        with assert_raises(zmq.ZMQError):
+        with pytest.raises(zmq.ZMQError):
             srv.bind('some_service')

     cnt = c.register_middleware(Resolver())
--- a/tests/test_server.py      2019-06-26 10:00:19.000000000 +0100
+++ b/tests/test_server.py      2021-12-21 18:33:16.501246624 +0000
@@ -27,7 +27,7 @@
 from __future__ import absolute_import
 from builtins import range

-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys

@@ -114,9 +114,9 @@
     client.connect(endpoint)

     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.TimeoutExpired, client.add, 1, 4)
+        pytest.raises(zerorpc.TimeoutExpired, client.add, 1, 4)
     else:
-        with assert_raises(zerorpc.TimeoutExpired):
+        with pytest.raises(zerorpc.TimeoutExpired):
             print(client.add(1, 4))
     client.close()
     srv.close()
@@ -140,9 +140,9 @@
     if sys.version_info < (2, 7):
         def _do_with_assert_raises():
             print(client.raise_something(42))
-        assert_raises(zerorpc.RemoteError, _do_with_assert_raises)
+        pytest.raises(zerorpc.RemoteError, _do_with_assert_raises)
     else:
-        with assert_raises(zerorpc.RemoteError):
+        with pytest.raises(zerorpc.RemoteError):
             print(client.raise_something(42))
     assert client.raise_something(list(range(5))) == 4
     client.close()
@@ -167,9 +167,9 @@
     if sys.version_info < (2, 7):
         def _do_with_assert_raises():
             print(client.raise_error())
-        assert_raises(zerorpc.RemoteError, _do_with_assert_raises)
+        pytest.raises(zerorpc.RemoteError, _do_with_assert_raises)
     else:
-        with assert_raises(zerorpc.RemoteError):
+        with pytest.raises(zerorpc.RemoteError):
             print(client.raise_error())
     try:
         client.raise_error()
--- a/tests/testutils.py        2019-06-26 10:00:19.000000000 +0100
+++ b/tests/testutils.py        2021-12-21 18:13:22.190745404 +0000
@@ -26,7 +26,7 @@
 from builtins import str

 import functools
-import nose.exc
+import pytest
 import random
 import os

@@ -52,7 +52,7 @@
     def _skip(test):
         @functools.wraps(test)
         def wrap():
-            raise nose.exc.SkipTest(reason)
+            raise pytest.SkipTest(reason)
         return wrap
     return _skip

--- a/tox.ini   2019-06-26 10:00:19.000000000 +0100
+++ b/tox.ini   2021-12-21 18:36:52.445964518 +0000
@@ -4,10 +4,10 @@
 [testenv]
 deps =
     flake8
-    nose
+    pytest
 commands =
     flake8 zerorpc bin
-    nosetests -v
+    pytest -v
 passenv = ZPC_TEST_TIME_FACTOR

 [flake8]
--- a/.travis.yml       2019-06-26 10:00:19.000000000 +0100
+++ b/.travis.yml       2021-12-21 18:36:36.519837814 +0000
@@ -27,4 +27,4 @@
   - if [ $TRAVIS_PYTHON_VERSION != '2.6' ]; then
     flake8 --ignore=E501,E128 zerorpc bin;
     fi
-  - nosetests -v
+  - pytest -v
```
That patch still not solves https://github.com/0rpc/zerorpc-python/issues/239 so this is why I'm ignoring for now that file.

Please let me know if you want above as PR.

Yes please. I would love a PR!

On Tue, 21 Dec 2021, 10:44 Tomasz Kłoczko, ***@***.***> wrote:

> Looks like it was easy to migrate so I've done that.
> Result:
>
> + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-zerorpc-0.6.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-zerorpc-0.6.3-2.fc35.x86_64/usr/lib/python3.8/site-packages+ /usr/bin/pytest -ra -p no:relaxed --ignore tests/test_client_async.py --deselect tests/test_server.py::test_exception_compat_v1=========================================================================== test session starts ============================================================================platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0rootdir: /home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3plugins: nose2pytest-1.0.8collected 78 items / 1 deselected / 77 selected
> tests/test_buffered_channel.py ..........                                                                                                                            [ 12%]tests/test_channel.py ...                                                                                                                                            [ 16%]tests/test_client.py ..                                                                                                                                              [ 19%]tests/test_client_heartbeat.py ......                                                                                                                                [ 27%]tests/test_events.py .......                                                                                                                                         [ 36%]tests/test_heartbeat.py ........                                                                                                                                     [ 46%]tests/test_middleware.py ..........                                                                                                                                  [ 59%]tests/test_middleware_before_after_exec.py .........                                                                                                                 [ 71%]tests/test_middleware_client.py ..........                                                                                                                           [ 84%]tests/test_pubpush.py ....                                                                                                                                           [ 89%]tests/test_reqstream.py .                                                                                                                                            [ 90%]tests/test_server.py ......                                                                                                                                          [ 98%]tests/test_zmq.py .                                                                                                                                                  [100%]
> ============================================================================= warnings summary =============================================================================tests/test_reqstream.py::test_rcp_streaming  /home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/tests/test_reqstream.py:61: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working    assert isinstance(r, collections.Iterator)
> -- Docs: https://docs.pytest.org/en/stable/warnings.html=============================================================== 77 passed, 1 deselected, 1 warning in 29.22s ===============================================================
>
> Here is the patch:
>
> --- a/setup.py  2019-06-26 10:00:19.000000000 +0100+++ b/setup.py  2021-12-21 17:53:43.738370582 +0000@@ -64,8 +64,8 @@
>      url='https://github.com/0rpc/zerorpc-python',
>      packages=['zerorpc'],
>      install_requires=requirements,-    tests_require=['nose'],-    test_suite='nose.collector',+    tests_require=['pytest'],+    test_suite='pytest.collector',
>      zip_safe=False,
>      entry_points={'console_scripts': ['zerorpc = zerorpc.cli:main']},
>      license='MIT',--- a/tests/test_buffered_channel.py    2019-06-26 10:00:19.000000000 +0100+++ b/tests/test_buffered_channel.py    2021-12-21 18:36:12.163644052 +0000@@ -27,7 +27,7 @@
>  from __future__ import absolute_import
>  from builtins import range
> -from nose.tools import assert_raises+import pytest
>  import gevent
>  import sys
> @@ -61,9 +61,9 @@
>      print('CLOSE SERVER SOCKET!!!')
>      server_bufchan.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              client_bufchan.recv()
>      print('CLIENT LOST SERVER :)')
>      client_bufchan.close()@@ -96,9 +96,9 @@
>      print('CLOSE CLIENT SOCKET!!!')
>      client_bufchan.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              client_bufchan.recv()
>      print('SERVER LOST CLIENT :)')
>      server_bufchan.close()@@ -129,9 +129,9 @@
>      print('CLOSE SERVER SOCKET!!!')
>      server_bufchan.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              client_bufchan.recv()
>      print('CLIENT LOST SERVER :)')
>      client_bufchan.close()@@ -170,9 +170,9 @@
>      client_bufchan.close()
>      client.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, server_coro.get)+        pytest.raises(zerorpc.LostRemote, server_coro.get)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              server_coro.get()
>      print('SERVER LOST CLIENT :)')
>      server.close()@@ -244,9 +244,9 @@
>              assert list(event.args) == [x + x * x]
>          client_bufchan.emit('add', (x, x * x))
>          if sys.version_info < (2, 7):-            assert_raises(zerorpc.LostRemote, client_bufchan.recv)+            pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
>          else:-            with assert_raises(zerorpc.LostRemote):+            with pytest.raises(zerorpc.LostRemote):
>                  client_bufchan.recv()
>          client_bufchan.close()
> @@ -308,9 +308,9 @@
>              server_bufchan.emit('OK', (sum(event.args),))
>
>          if sys.version_info < (2, 7):-            assert_raises(zerorpc.LostRemote, server_bufchan.recv)+            pytest.raises(zerorpc.LostRemote, server_bufchan.recv)
>          else:-            with assert_raises(zerorpc.LostRemote):+            with pytest.raises(zerorpc.LostRemote):
>                  server_bufchan.recv()
>          server_bufchan.close()
> @@ -343,9 +343,9 @@
>                      event = client_bufchan.recv(timeout=TIME_FACTOR * 3)
>                      assert event.name == 'OK'
>                      assert list(event.args) == [x]-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
>          else:-            with assert_raises(zerorpc.TimeoutExpired):+            with pytest.raises(zerorpc.TimeoutExpired):
>                  for x in range(10):
>                      client_bufchan.emit('sleep', (x,))
>                      event = client_bufchan.recv(timeout=TIME_FACTOR * 3)@@ -369,9 +369,9 @@
>                      assert event.name == 'sleep'
>                      gevent.sleep(TIME_FACTOR * event.args[0])
>                      server_bufchan.emit('OK', event.args)-            assert_raises(zerorpc.LostRemote, _do_with_assert_raises)+            pytest.raises(zerorpc.LostRemote, _do_with_assert_raises)
>          else:-            with assert_raises(zerorpc.LostRemote):+            with pytest.raises(zerorpc.LostRemote):
>                  for x in range(20):
>                      event = server_bufchan.recv()
>                      assert event.name == 'sleep'@@ -422,9 +422,9 @@
>              def _do_with_assert_raises():
>                  for x in range(200):
>                      server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 1-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
>          else:-            with assert_raises(zerorpc.TimeoutExpired):+            with pytest.raises(zerorpc.TimeoutExpired):
>                  for x in range(200):
>                      server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 1
>          server_bufchan.emit('coucou', 1)  # block until receiver is ready@@ -432,9 +432,9 @@
>              def _do_with_assert_raises():
>                  for x in range(2, 200):
>                      server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 100-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
>          else:-            with assert_raises(zerorpc.TimeoutExpired):+            with pytest.raises(zerorpc.TimeoutExpired):
>                  for x in range(2, 200):
>                      server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 100
>          for x in range(read_cnt.value, 200):--- a/tests/test_client_async.py        2019-06-26 10:00:19.000000000 +0100+++ b/tests/test_client_async.py        2021-12-21 18:34:33.983863012 +0000@@ -25,7 +25,7 @@
>
>  from __future__ import print_function
>  from __future__ import absolute_import-from nose.tools import assert_raises+import pytest
>  import gevent
>  import sys
> @@ -58,9 +58,9 @@
>      if sys.version_info < (2, 7):
>          def _do_with_assert_raises():
>              print(async_result.get())-        assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)+        pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
>      else:-        with assert_raises(zerorpc.TimeoutExpired):+        with pytest.raises(zerorpc.TimeoutExpired):
>              print(async_result.get())
>      client.close()
>      srv.close()--- a/tests/test_heartbeat.py   2019-06-26 10:00:19.000000000 +0100+++ b/tests/test_heartbeat.py   2021-12-21 18:30:10.115763883 +0000@@ -27,7 +27,7 @@
>  from __future__ import absolute_import
>  from builtins import range
> -from nose.tools import assert_raises+import pytest
>  import gevent
>  import sys
> @@ -59,9 +59,9 @@
>      print('CLOSE SERVER SOCKET!!!')
>      server_hbchan.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, client_hbchan.recv)+        pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              client_hbchan.recv()
>      print('CLIENT LOST SERVER :)')
>      client_hbchan.close()@@ -92,9 +92,9 @@
>      print('CLOSE CLIENT SOCKET!!!')
>      client_hbchan.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, server_hbchan.recv)+        pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              server_hbchan.recv()
>      print('SERVER LOST CLIENT :)')
>      server_hbchan.close()@@ -123,9 +123,9 @@
>      print('CLOSE SERVER SOCKET!!!')
>      server_hbchan.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, client_hbchan.recv)+        pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              client_hbchan.recv()
>      print('CLIENT LOST SERVER :)')
>      client_hbchan.close()@@ -155,9 +155,9 @@
>      client_hbchan.close()
>      client.close()
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.LostRemote, server_hbchan.recv)+        pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
>      else:-        with assert_raises(zerorpc.LostRemote):+        with pytest.raises(zerorpc.LostRemote):
>              server_hbchan.recv()
>      print('SERVER LOST CLIENT :)')
>      server_hbchan.close()@@ -227,9 +227,9 @@
>              assert list(event.args) == [x + x * x]
>          client_hbchan.emit('add', (x, x * x))
>          if sys.version_info < (2, 7):-            assert_raises(zerorpc.LostRemote, client_hbchan.recv)+            pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
>          else:-            with assert_raises(zerorpc.LostRemote):+            with pytest.raises(zerorpc.LostRemote):
>                  client_hbchan.recv()
>          client_hbchan.close()
> @@ -287,9 +287,9 @@
>              server_hbchan.emit('OK', (sum(event.args),))
>
>          if sys.version_info < (2, 7):-            assert_raises(zerorpc.LostRemote, server_hbchan.recv)+            pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
>          else:-            with assert_raises(zerorpc.LostRemote):+            with pytest.raises(zerorpc.LostRemote):
>                  server_hbchan.recv()
>          server_hbchan.close()
> @@ -322,9 +322,9 @@
>                      event = client_hbchan.recv(timeout=TIME_FACTOR * 3)
>                      assert event.name == 'OK'
>                      assert list(event.args) == [x]-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
>          else:-            with assert_raises(zerorpc.TimeoutExpired):+            with pytest.raises(zerorpc.TimeoutExpired):
>                  for x in range(10):
>                      client_hbchan.emit('sleep', (x,))
>                      event = client_hbchan.recv(timeout=TIME_FACTOR * 3)@@ -346,9 +346,9 @@
>                      assert event.name == 'sleep'
>                      gevent.sleep(TIME_FACTOR * event.args[0])
>                      server_hbchan.emit('OK', event.args)-            assert_raises(zerorpc.LostRemote, _do_with_assert_raises)+            pytest.raises(zerorpc.LostRemote, _do_with_assert_raises)
>          else:-            with assert_raises(zerorpc.LostRemote):+            with pytest.raises(zerorpc.LostRemote):
>                  for x in range(20):
>                      event = server_hbchan.recv()
>                      assert event.name == 'sleep'--- a/tests/test_middleware.py  2019-06-26 10:00:19.000000000 +0100+++ b/tests/test_middleware.py  2021-12-21 18:32:15.475761150 +0000@@ -28,7 +28,7 @@
>  from builtins import str
>  from future.utils import tobytes
> -from nose.tools import assert_raises+import pytest
>  import gevent
>  import gevent.local
>  import random@@ -101,9 +101,9 @@
>
>      srv = Srv(heartbeat=TIME_FACTOR * 1, context=c)
>      if sys.version_info < (2, 7):-        assert_raises(zmq.ZMQError, srv.bind, 'some_service')+        pytest.raises(zmq.ZMQError, srv.bind, 'some_service')
>      else:-        with assert_raises(zmq.ZMQError):+        with pytest.raises(zmq.ZMQError):
>              srv.bind('some_service')
>
>      cnt = c.register_middleware(Resolver())--- a/tests/test_server.py      2019-06-26 10:00:19.000000000 +0100+++ b/tests/test_server.py      2021-12-21 18:33:16.501246624 +0000@@ -27,7 +27,7 @@
>  from __future__ import absolute_import
>  from builtins import range
> -from nose.tools import assert_raises+import pytest
>  import gevent
>  import sys
> @@ -114,9 +114,9 @@
>      client.connect(endpoint)
>
>      if sys.version_info < (2, 7):-        assert_raises(zerorpc.TimeoutExpired, client.add, 1, 4)+        pytest.raises(zerorpc.TimeoutExpired, client.add, 1, 4)
>      else:-        with assert_raises(zerorpc.TimeoutExpired):+        with pytest.raises(zerorpc.TimeoutExpired):
>              print(client.add(1, 4))
>      client.close()
>      srv.close()@@ -140,9 +140,9 @@
>      if sys.version_info < (2, 7):
>          def _do_with_assert_raises():
>              print(client.raise_something(42))-        assert_raises(zerorpc.RemoteError, _do_with_assert_raises)+        pytest.raises(zerorpc.RemoteError, _do_with_assert_raises)
>      else:-        with assert_raises(zerorpc.RemoteError):+        with pytest.raises(zerorpc.RemoteError):
>              print(client.raise_something(42))
>      assert client.raise_something(list(range(5))) == 4
>      client.close()@@ -167,9 +167,9 @@
>      if sys.version_info < (2, 7):
>          def _do_with_assert_raises():
>              print(client.raise_error())-        assert_raises(zerorpc.RemoteError, _do_with_assert_raises)+        pytest.raises(zerorpc.RemoteError, _do_with_assert_raises)
>      else:-        with assert_raises(zerorpc.RemoteError):+        with pytest.raises(zerorpc.RemoteError):
>              print(client.raise_error())
>      try:
>          client.raise_error()--- a/tests/testutils.py        2019-06-26 10:00:19.000000000 +0100+++ b/tests/testutils.py        2021-12-21 18:13:22.190745404 +0000@@ -26,7 +26,7 @@
>  from builtins import str
>
>  import functools-import nose.exc+import pytest
>  import random
>  import os
> @@ -52,7 +52,7 @@
>      def _skip(test):
>          @functools.wraps(test)
>          def wrap():-            raise nose.exc.SkipTest(reason)+            raise pytest.SkipTest(reason)
>          return wrap
>      return _skip
> --- a/tox.ini   2019-06-26 10:00:19.000000000 +0100+++ b/tox.ini   2021-12-21 18:36:52.445964518 +0000@@ -4,10 +4,10 @@
>  [testenv]
>  deps =
>      flake8-    nose+    pytest
>  commands =
>      flake8 zerorpc bin-    nosetests -v+    pytest -v
>  passenv = ZPC_TEST_TIME_FACTOR
>
>  [flake8]--- a/.travis.yml       2019-06-26 10:00:19.000000000 +0100+++ b/.travis.yml       2021-12-21 18:36:36.519837814 +0000@@ -27,4 +27,4 @@
>    - if [ $TRAVIS_PYTHON_VERSION != '2.6' ]; then
>      flake8 --ignore=E501,E128 zerorpc bin;
>      fi-  - nosetests -v+  - pytest -v
>
> That patch still not solves #239
> <https://github.com/0rpc/zerorpc-python/issues/239> so this is why I'm
> ignoring for now that file.
>
> Please let me know if you want above as PR.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/0rpc/zerorpc-python/issues/243#issuecomment-999010575>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABUZDBTCYTMAWWKVS6FA73USDDIRANCNFSM5KQXIMOA>
> .
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
>
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>

> That patch still not solves #239 so this is why I'm ignoring for now that file.

I would propose #245 

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index c01068d..67c2d20 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,4 +29,4 @@ script:
   - if [ $TRAVIS_PYTHON_VERSION != '2.6' ]; then
     flake8 --ignore=E501,E128 zerorpc bin;
     fi
-  - nosetests -v
+  - pytest -v
diff --git a/setup.py b/setup.py
index 610e68b..b07ebcb 100644
--- a/setup.py
+++ b/setup.py
@@ -64,8 +64,8 @@
     url='https://github.com/0rpc/zerorpc-python',
     packages=['zerorpc'],
     install_requires=requirements,
-    tests_require=['nose'],
-    test_suite='nose.collector',
+    tests_require=['pytest'],
+    test_suite='pytest.collector',
     zip_safe=False,
     entry_points={'console_scripts': ['zerorpc = zerorpc.cli:main']},
     license='MIT',
diff --git a/tox.ini b/tox.ini
index 3490b2c..96bace8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -4,10 +4,10 @@ envlist = py26,py27,py34,py35
 [testenv]
 deps =
     flake8
-    nose
+    pytest
 commands =
     flake8 zerorpc bin
-    nosetests -v
+    pytest -v
 passenv = ZPC_TEST_TIME_FACTOR
 
 [flake8]


Test patch:
diff --git a/tests/test_buffered_channel.py b/tests/test_buffered_channel.py
index 76d0fe3..20b8173 100644
--- a/tests/test_buffered_channel.py
+++ b/tests/test_buffered_channel.py
@@ -27,7 +27,7 @@
 from __future__ import absolute_import
 from builtins import range
 
-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys
 
@@ -61,9 +61,9 @@ def test_close_server_bufchan():
     print('CLOSE SERVER SOCKET!!!')
     server_bufchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_bufchan.recv()
     print('CLIENT LOST SERVER :)')
     client_bufchan.close()
@@ -96,9 +96,9 @@ def test_close_client_bufchan():
     print('CLOSE CLIENT SOCKET!!!')
     client_bufchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_bufchan.recv()
     print('SERVER LOST CLIENT :)')
     server_bufchan.close()
@@ -129,9 +129,9 @@ def test_heartbeat_can_open_channel_server_close():
     print('CLOSE SERVER SOCKET!!!')
     server_bufchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_bufchan.recv()
     print('CLIENT LOST SERVER :)')
     client_bufchan.close()
@@ -170,9 +170,9 @@ def server_fn():
     client_bufchan.close()
     client.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, server_coro.get)
+        pytest.raises(zerorpc.LostRemote, server_coro.get)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             server_coro.get()
     print('SERVER LOST CLIENT :)')
     server.close()
@@ -244,9 +244,9 @@ def client_do():
             assert list(event.args) == [x + x * x]
         client_bufchan.emit('add', (x, x * x))
         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, client_bufchan.recv)
+            pytest.raises(zerorpc.LostRemote, client_bufchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 client_bufchan.recv()
         client_bufchan.close()
 
@@ -308,9 +308,9 @@ def server_do():
             server_bufchan.emit('OK', (sum(event.args),))
 
         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, server_bufchan.recv)
+            pytest.raises(zerorpc.LostRemote, server_bufchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 server_bufchan.recv()
         server_bufchan.close()
 
@@ -343,9 +343,9 @@ def _do_with_assert_raises():
                     event = client_bufchan.recv(timeout=TIME_FACTOR * 3)
                     assert event.name == 'OK'
                     assert list(event.args) == [x]
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(10):
                     client_bufchan.emit('sleep', (x,))
                     event = client_bufchan.recv(timeout=TIME_FACTOR * 3)
@@ -369,9 +369,9 @@ def _do_with_assert_raises():
                     assert event.name == 'sleep'
                     gevent.sleep(TIME_FACTOR * event.args[0])
                     server_bufchan.emit('OK', event.args)
-            assert_raises(zerorpc.LostRemote, _do_with_assert_raises)
+            pytest.raises(zerorpc.LostRemote, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 for x in range(20):
                     event = server_bufchan.recv()
                     assert event.name == 'sleep'
@@ -422,9 +422,9 @@ def server_do():
             def _do_with_assert_raises():
                 for x in range(200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 1
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 1
         server_bufchan.emit('coucou', 1)  # block until receiver is ready
@@ -432,9 +432,9 @@ def _do_with_assert_raises():
             def _do_with_assert_raises():
                 for x in range(2, 200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 100
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(2, 200):
                     server_bufchan.emit('coucou', x, timeout=0)  # will fail when x == 100
         for x in range(read_cnt.value, 200):
diff --git a/tests/test_client_async.py b/tests/test_client_async.py
index 3acbd3b..7d39364 100644
--- a/tests/test_client_async.py
+++ b/tests/test_client_async.py
@@ -25,7 +25,7 @@
 
 from __future__ import print_function
 from __future__ import absolute_import
-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys
 
@@ -58,9 +58,9 @@ def add(self, a, b):
     if sys.version_info < (2, 7):
         def _do_with_assert_raises():
             print(async_result.get())
-        assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+        pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
     else:
-        with assert_raises(zerorpc.TimeoutExpired):
+        with pytest.raises(zerorpc.TimeoutExpired):
             print(async_result.get())
     client.close()
     srv.close()
diff --git a/tests/test_heartbeat.py b/tests/test_heartbeat.py
index 75b1d29..14c66fd 100644
--- a/tests/test_heartbeat.py
+++ b/tests/test_heartbeat.py
@@ -27,7 +27,7 @@
 from __future__ import absolute_import
 from builtins import range
 
-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys
 
@@ -59,9 +59,9 @@ def test_close_server_hbchan():
     print('CLOSE SERVER SOCKET!!!')
     server_hbchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_hbchan.recv()
     print('CLIENT LOST SERVER :)')
     client_hbchan.close()
@@ -92,9 +92,9 @@ def test_close_client_hbchan():
     print('CLOSE CLIENT SOCKET!!!')
     client_hbchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, server_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             server_hbchan.recv()
     print('SERVER LOST CLIENT :)')
     server_hbchan.close()
@@ -123,9 +123,9 @@ def test_heartbeat_can_open_channel_server_close():
     print('CLOSE SERVER SOCKET!!!')
     server_hbchan.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, client_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             client_hbchan.recv()
     print('CLIENT LOST SERVER :)')
     client_hbchan.close()
@@ -155,9 +155,9 @@ def test_heartbeat_can_open_channel_client_close():
     client_hbchan.close()
     client.close()
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.LostRemote, server_hbchan.recv)
+        pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
     else:
-        with assert_raises(zerorpc.LostRemote):
+        with pytest.raises(zerorpc.LostRemote):
             server_hbchan.recv()
     print('SERVER LOST CLIENT :)')
     server_hbchan.close()
@@ -227,9 +227,9 @@ def client_do():
             assert list(event.args) == [x + x * x]
         client_hbchan.emit('add', (x, x * x))
         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, client_hbchan.recv)
+            pytest.raises(zerorpc.LostRemote, client_hbchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 client_hbchan.recv()
         client_hbchan.close()
 
@@ -287,9 +287,9 @@ def server_do():
             server_hbchan.emit('OK', (sum(event.args),))
 
         if sys.version_info < (2, 7):
-            assert_raises(zerorpc.LostRemote, server_hbchan.recv)
+            pytest.raises(zerorpc.LostRemote, server_hbchan.recv)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 server_hbchan.recv()
         server_hbchan.close()
 
@@ -322,9 +322,9 @@ def _do_with_assert_raises():
                     event = client_hbchan.recv(timeout=TIME_FACTOR * 3)
                     assert event.name == 'OK'
                     assert list(event.args) == [x]
-            assert_raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
+            pytest.raises(zerorpc.TimeoutExpired, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.TimeoutExpired):
+            with pytest.raises(zerorpc.TimeoutExpired):
                 for x in range(10):
                     client_hbchan.emit('sleep', (x,))
                     event = client_hbchan.recv(timeout=TIME_FACTOR * 3)
@@ -346,9 +346,9 @@ def _do_with_assert_raises():
                     assert event.name == 'sleep'
                     gevent.sleep(TIME_FACTOR * event.args[0])
                     server_hbchan.emit('OK', event.args)
-            assert_raises(zerorpc.LostRemote, _do_with_assert_raises)
+            pytest.raises(zerorpc.LostRemote, _do_with_assert_raises)
         else:
-            with assert_raises(zerorpc.LostRemote):
+            with pytest.raises(zerorpc.LostRemote):
                 for x in range(20):
                     event = server_hbchan.recv()
                     assert event.name == 'sleep'
diff --git a/tests/test_middleware.py b/tests/test_middleware.py
index 754f8cb..3163a3a 100644
--- a/tests/test_middleware.py
+++ b/tests/test_middleware.py
@@ -28,7 +28,7 @@
 from builtins import str
 from future.utils import tobytes
 
-from nose.tools import assert_raises
+import pytest
 import gevent
 import gevent.local
 import random
@@ -101,9 +101,9 @@ def hello(self):
 
     srv = Srv(heartbeat=TIME_FACTOR * 1, context=c)
     if sys.version_info < (2, 7):
-        assert_raises(zmq.ZMQError, srv.bind, 'some_service')
+        pytest.raises(zmq.ZMQError, srv.bind, 'some_service')
     else:
-        with assert_raises(zmq.ZMQError):
+        with pytest.raises(zmq.ZMQError):
             srv.bind('some_service')
 
     cnt = c.register_middleware(Resolver())
diff --git a/tests/test_server.py b/tests/test_server.py
index 2a266ce..86997a9 100644
--- a/tests/test_server.py
+++ b/tests/test_server.py
@@ -27,7 +27,7 @@
 from __future__ import absolute_import
 from builtins import range
 
-from nose.tools import assert_raises
+import pytest
 import gevent
 import sys
 
@@ -114,9 +114,9 @@ def add(self, a, b):
     client.connect(endpoint)
 
     if sys.version_info < (2, 7):
-        assert_raises(zerorpc.TimeoutExpired, client.add, 1, 4)
+        pytest.raises(zerorpc.TimeoutExpired, client.add, 1, 4)
     else:
-        with assert_raises(zerorpc.TimeoutExpired):
+        with pytest.raises(zerorpc.TimeoutExpired):
             print(client.add(1, 4))
     client.close()
     srv.close()
@@ -140,9 +140,9 @@ def raise_something(self, a):
     if sys.version_info < (2, 7):
         def _do_with_assert_raises():
             print(client.raise_something(42))
-        assert_raises(zerorpc.RemoteError, _do_with_assert_raises)
+        pytest.raises(zerorpc.RemoteError, _do_with_assert_raises)
     else:
-        with assert_raises(zerorpc.RemoteError):
+        with pytest.raises(zerorpc.RemoteError):
             print(client.raise_something(42))
     assert client.raise_something(list(range(5))) == 4
     client.close()
@@ -167,9 +167,9 @@ def raise_error(self):
     if sys.version_info < (2, 7):
         def _do_with_assert_raises():
             print(client.raise_error())
-        assert_raises(zerorpc.RemoteError, _do_with_assert_raises)
+        pytest.raises(zerorpc.RemoteError, _do_with_assert_raises)
     else:
-        with assert_raises(zerorpc.RemoteError):
+        with pytest.raises(zerorpc.RemoteError):
             print(client.raise_error())
     try:
         client.raise_error()
diff --git a/tests/testutils.py b/tests/testutils.py
index 2a0110c..85b6a96 100644
--- a/tests/testutils.py
+++ b/tests/testutils.py
@@ -26,7 +26,7 @@
 from builtins import str
 
 import functools
-import nose.exc
+import pytest
 import random
 import os
 
@@ -52,7 +52,7 @@ def skip(reason):
     def _skip(test):
         @functools.wraps(test)
         def wrap():
-            raise nose.exc.SkipTest(reason)
+            raise pytest.SkipTest(reason)
         return wrap
     return _skip