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

0.6.3: test suite is using nose module #243

Open
kloczek opened this issue Dec 21, 2021 · 10 comments
Open

0.6.3: test suite is using nose module #243

kloczek opened this issue Dec 21, 2021 · 10 comments

Comments

@kloczek
Copy link
Contributor

kloczek commented Dec 21, 2021

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/

@kloczek
Copy link
Contributor Author

kloczek commented Dec 21, 2021

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.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:

--- 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 so this is why I'm ignoring for now that file.

Please let me know if you want above as PR.

@bombela
Copy link
Member

bombela commented Jan 5, 2022 via email

@chombourger
Copy link
Contributor

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

I would propose #245

@kloczek
Copy link
Contributor Author

kloczek commented Jan 6, 2022

Yes please. I would love a PR!

Done #247

bombela added a commit that referenced this issue Jan 6, 2022
Move from deprecated nose to pytest (solves #243)
@bombela
Copy link
Member

bombela commented Jan 6, 2022 via email

@kloczek
Copy link
Contributor Author

kloczek commented Jan 6, 2022

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

I would propose #245

Just tested that and pytest still fails for me but it may be result of my patch with nose to pytest migration.
As please have look on pytest warnig.

[tkloczko@ss-desktop SPECS]$ rpmbuild -ba --with failing_tests python-zerorpc.spec
warning: Downloading https://github.com/0rpc/zerorpc-python//archive/v0.6.3/python-zerorpc-0.6.3.tar.gz to /home/tkloczko/rpmbuild/SOURCES/python-zerorpc-0.6.3.tar.gz
warning: Downloading https://github.com/0rpc/zerorpc-python//commit/d6346f56.patch#/python-zerorpc-core-handle-both-async-and-async_-in-remote-calls.patch to /home/tkloczko/rpmbuild/SOURCES/python-zerorpc-core-handle-both-async-and-async_-in-remote-calls.patch
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.aoKgQN
+ umask 022
+ cd /home/tkloczko/rpmbuild/BUILD
+ cd /home/tkloczko/rpmbuild/BUILD
+ rm -rf zerorpc-python-0.6.3
+ /usr/bin/gzip -dc /home/tkloczko/rpmbuild/SOURCES/python-zerorpc-0.6.3.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd zerorpc-python-0.6.3
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-zerorpc-nose2pytest.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ /usr/bin/cat /home/tkloczko/rpmbuild/SOURCES/python-zerorpc-core-handle-both-async-and-async_-in-remote-calls.patch
+ /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f
+ RPM_EC=0
++ jobs -p
+ exit 0

[..]

+ 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
=========================================================================== 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
collected 80 items

tests/test_buffered_channel.py ..........                                                                                                                            [ 12%]
tests/test_channel.py ...                                                                                                                                            [ 16%]
tests/test_client.py ..                                                                                                                                              [ 18%]
tests/test_client_async.py ..                                                                                                                                        [ 21%]
tests/test_client_heartbeat.py ......                                                                                                                                [ 28%]
tests/test_events.py .......                                                                                                                                         [ 37%]
tests/test_heartbeat.py ........                                                                                                                                     [ 47%]
tests/test_middleware.py ..........                                                                                                                                  [ 60%]
tests/test_middleware_before_after_exec.py ......F..                                                                                                                 [ 71%]
tests/test_middleware_client.py ..........                                                                                                                           [ 83%]
tests/test_pubpush.py ....                                                                                                                                           [ 88%]
tests/test_reqstream.py .                                                                                                                                            [ 90%]
tests/test_server.py .....F.                                                                                                                                         [ 98%]
tests/test_zmq.py .                                                                                                                                                  [100%]

================================================================================= FAILURES =================================================================================
___________________________________________________________________ test_hook_server_after_exec_on_error ___________________________________________________________________

self = <zerorpc.channel.BufferedChannel object at 0x7f38781a4c10>, timeout = 30

    def recv(self, timeout=None):
        # self._channel can be set to None by an 'on_close_if' callback if it
        # sees a suitable message from the remote end...
        #
        if self._verbose and self._channel:
            if self._input_queue_reserved < self._input_queue_size // 2:
                self._request_data()
        else:
            self._verbose = True

        try:
>           event = self._input_queue.get(timeout=timeout)

zerorpc/channel.py:255:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/queue.py:335:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/queue.py:350:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/queue.py:327:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/_waiter.py:154:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/_greenlet_primitives.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/_greenlet_primitives.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???

src/gevent/_greenlet_primitives.py:65:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   _queue.Empty

src/gevent/_gevent_c_greenlet_primitives.pxd:35: Empty

During handling of the above exception, another exception occurred:

self = <zerorpc.core.Client object at 0x7f38781a4940>, request_event = <zerorpc.events.Event object at 0x7f38781aaf80>
bufchan = <zerorpc.channel.BufferedChannel object at 0x7f38781a4c10>, timeout = 30

    def _process_response(self, request_event, bufchan, timeout):
        def raise_error(ex):
            bufchan.close()
            self._context.hook_client_after_request(request_event, None, ex)
            raise ex

        try:
>           reply_event = bufchan.recv(timeout=timeout)

zerorpc/core.py:227:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <zerorpc.channel.BufferedChannel object at 0x7f38781a4c10>, timeout = 30

    def recv(self, timeout=None):
        # self._channel can be set to None by an 'on_close_if' callback if it
        # sees a suitable message from the remote end...
        #
        if self._verbose and self._channel:
            if self._input_queue_reserved < self._input_queue_size // 2:
                self._request_data()
        else:
            self._verbose = True

        try:
            event = self._input_queue.get(timeout=timeout)
        except gevent.queue.Empty:
>           raise TimeoutExpired(timeout)
E           zerorpc.exceptions.TimeoutExpired: timeout after 30s

zerorpc/channel.py:257: TimeoutExpired

During handling of the above exception, another exception occurred:

    def test_hook_server_after_exec_on_error():
        zero_ctx = zerorpc.Context()
        endpoint = random_ipc_endpoint()

        test_server = zerorpc.Server(BrokenEchoModule(), context=zero_ctx)
        test_server.bind(endpoint)
        test_server_task = gevent.spawn(test_server.run)
        test_client = zerorpc.Client()
        test_client.connect(endpoint)

        test_middleware = ServerAfterExecMiddleware()
        zero_ctx.register_middleware(test_middleware)
        assert test_middleware.called == False
        try:
>           test_client.echo("test")

tests/test_middleware_before_after_exec.py:269:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
zerorpc/core.py:281: in <lambda>
    return lambda *args, **kargs: self(method, *args, **kargs)
zerorpc/core.py:273: in __call__
    return self._process_response(request_event, bufchan, timeout)
zerorpc/core.py:229: in _process_response
    raise_error(TimeoutExpired(timeout,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

ex = TimeoutExpired('timeout after 30s, when calling remote method echo')

    def raise_error(ex):
        bufchan.close()
        self._context.hook_client_after_request(request_event, None, ex)
>       raise ex
E       zerorpc.exceptions.TimeoutExpired: timeout after 30s, when calling remote method echo

zerorpc/core.py:224: TimeoutExpired
------------------------------------------------------------------------- Captured stdout teardown -------------------------------------------------------------------------
unlink /tmp/zerorpc_test_socket_7042481083751932.sock
_________________________________________________________________________ test_exception_compat_v1 _________________________________________________________________________

    def test_exception_compat_v1():
        endpoint = random_ipc_endpoint()

        class MySrv(zerorpc.Server):
            pass

        srv = MySrv()
        srv.bind(endpoint)
        gevent.spawn(srv.run)

        client_events = zerorpc.Events(zmq.DEALER)
        client_events.connect(endpoint)
        client = zerorpc.ChannelMultiplexer(client_events, ignore_broadcast=True)

        rpccall = client.channel()
        rpccall.emit('donotexist', tuple())
        event = rpccall.recv()
        print(event)
        assert event.name == 'ERR'
        (name, msg, tb) = event.args
        print('detailed error', name, msg, tb)
        assert name == 'NameError'
        assert msg == 'donotexist'

        rpccall = client.channel()
        rpccall.emit('donotexist', tuple(), xheader={'v': 1})
        event = rpccall.recv()
        print(event)
        assert event.name == 'ERR'
        (msg,) = event.args
        print('msg only', msg)
>       assert msg == "NameError('donotexist',)"
E       assert "NameError('donotexist')" == "NameError('donotexist',)"
E         - NameError('donotexist',)
E         ?                       -
E         + NameError('donotexist')

tests/test_server.py:218: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
<b''> ERR {'message_id': b'f872476e76184777a7485b464bd4028e', 'v': 3, 'response_to': b'f872476d76184777a7485b464bd4028e'} ['NameError', 'donotexist', 'Traceback (most recent call last):\n  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task\n    raise NameError(event.name)\nNameError: donotexist\n']
detailed error NameError donotexist Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task
    raise NameError(event.name)
NameError: donotexist

<b''> ERR {'message_id': b'f872477076184777a7485b464bd4028e', 'v': 3, 'response_to': b'f872476f76184777a7485b464bd4028e'} ["NameError('donotexist')"]
msg only NameError('donotexist')
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
ERROR    zerorpc.core:core.py:130
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task
    raise NameError(event.name)
NameError: donotexist
ERROR    zerorpc.core:core.py:130
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task
    raise NameError(event.name)
NameError: donotexist
------------------------------------------------------------------------- Captured stdout teardown -------------------------------------------------------------------------
unlink /tmp/zerorpc_test_socket_631593270723546.sock
============================================================================= 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
========================================================================= short test summary info ==========================================================================
FAILED tests/test_middleware_before_after_exec.py::test_hook_server_after_exec_on_error - zerorpc.exceptions.TimeoutExpired: timeout after 30s, when calling remote metho...
FAILED tests/test_server.py::test_exception_compat_v1 - assert "NameError('donotexist')" == "NameError('donotexist',)"
============================================================ 2 failed, 78 passed, 1 warning in 78.97s (0:01:18) ============================================================

@kloczek
Copy link
Contributor Author

kloczek commented Jan 6, 2022

Something is strange. On second run I have only one unit failed

+ 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
=========================================================================== 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
collected 80 items

tests/test_buffered_channel.py ..........                                                                                                                            [ 12%]
tests/test_channel.py ...                                                                                                                                            [ 16%]
tests/test_client.py ..                                                                                                                                              [ 18%]
tests/test_client_async.py ..                                                                                                                                        [ 21%]
tests/test_client_heartbeat.py ......                                                                                                                                [ 28%]
tests/test_events.py .......                                                                                                                                         [ 37%]
tests/test_heartbeat.py ........                                                                                                                                     [ 47%]
tests/test_middleware.py ..........                                                                                                                                  [ 60%]
tests/test_middleware_before_after_exec.py .........                                                                                                                 [ 71%]
tests/test_middleware_client.py ..........                                                                                                                           [ 83%]
tests/test_pubpush.py ....                                                                                                                                           [ 88%]
tests/test_reqstream.py .                                                                                                                                            [ 90%]
tests/test_server.py .....F.                                                                                                                                         [ 98%]
tests/test_zmq.py .                                                                                                                                                  [100%]

================================================================================= FAILURES =================================================================================
_________________________________________________________________________ test_exception_compat_v1 _________________________________________________________________________

    def test_exception_compat_v1():
        endpoint = random_ipc_endpoint()

        class MySrv(zerorpc.Server):
            pass

        srv = MySrv()
        srv.bind(endpoint)
        gevent.spawn(srv.run)

        client_events = zerorpc.Events(zmq.DEALER)
        client_events.connect(endpoint)
        client = zerorpc.ChannelMultiplexer(client_events, ignore_broadcast=True)

        rpccall = client.channel()
        rpccall.emit('donotexist', tuple())
        event = rpccall.recv()
        print(event)
        assert event.name == 'ERR'
        (name, msg, tb) = event.args
        print('detailed error', name, msg, tb)
        assert name == 'NameError'
        assert msg == 'donotexist'

        rpccall = client.channel()
        rpccall.emit('donotexist', tuple(), xheader={'v': 1})
        event = rpccall.recv()
        print(event)
        assert event.name == 'ERR'
        (msg,) = event.args
        print('msg only', msg)
>       assert msg == "NameError('donotexist',)"
E       assert "NameError('donotexist')" == "NameError('donotexist',)"
E         - NameError('donotexist',)
E         ?                       -
E         + NameError('donotexist')

tests/test_server.py:218: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
<b''> ERR {'message_id': b'cf06f481fd5b4daaabfd7b4f19d07f7a', 'v': 3, 'response_to': b'cf06f480fd5b4daaabfd7b4f19d07f7a'} ['NameError', 'donotexist', 'Traceback (most recent call last):\n  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task\n    raise NameError(event.name)\nNameError: donotexist\n']
detailed error NameError donotexist Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task
    raise NameError(event.name)
NameError: donotexist

<b''> ERR {'message_id': b'cf06f483fd5b4daaabfd7b4f19d07f7a', 'v': 3, 'response_to': b'cf06f482fd5b4daaabfd7b4f19d07f7a'} ["NameError('donotexist')"]
msg only NameError('donotexist')
---------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
ERROR    zerorpc.core:core.py:130
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task
    raise NameError(event.name)
NameError: donotexist
ERROR    zerorpc.core:core.py:130
Traceback (most recent call last):
  File "/home/tkloczko/rpmbuild/BUILD/zerorpc-python-0.6.3/zerorpc/core.py", line 152, in _async_task
    raise NameError(event.name)
NameError: donotexist
------------------------------------------------------------------------- Captured stdout teardown -------------------------------------------------------------------------
unlink /tmp/zerorpc_test_socket_2540000683684066.sock
============================================================================= 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
========================================================================= short test summary info ==========================================================================
FAILED tests/test_server.py::test_exception_compat_v1 - assert "NameError('donotexist')" == "NameError('donotexist',)"
================================================================= 1 failed, 79 passed, 1 warning in 29.97s =================================================================

@kloczek
Copy link
Contributor Author

kloczek commented Jan 6, 2022

Running another 5 times I had 1 tiem two units failing and 4 times 1 unit :/

@bombela
Copy link
Member

bombela commented Jan 6, 2022 via email

@chombourger
Copy link
Contributor

On my side, the only pytest failure left on my Debian 11 system running HEAD is:

>       assert msg == "NameError('donotexist',)"
E       assert "NameError('donotexist')" == "NameError('donotexist',)"
E         - NameError('donotexist',)
E         ?                       -
E         + NameError('donotexist')

tests/test_server.py:220: AssertionError

checking what is going on...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants