[go: nahoru, domu]

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

Replace asynctest with std solution #135

Closed
ixje opened this issue Oct 27, 2021 · 1 comment · Fixed by #196
Closed

Replace asynctest with std solution #135

ixje opened this issue Oct 27, 2021 · 1 comment · Fixed by #196
Assignees

Comments

@ixje
Copy link
Member
ixje commented Oct 27, 2021

asynctest is currently used to test the NeoNode and the convenience manager classes in the network package of mamba. While it still works, people are reporting issues with Python 3.8 and 3.9 on the asynctest repo. It has not had an update in 2 years and the author indicated he is not maintaining it.

From Python3.8 upwards std's unittest has a new test class IsolatedAsyncioTestCase and AsyncMock that should make it possible to drop asyntest. The main thing to figure out is probably how/what to replace asynctest.SocketMock with.

@ixje
Copy link
Member Author
ixje commented Apr 5, 2022

I actually made an attempt to use python-mocket but it's main focus seems to be more to support http like requests. It patches socket.socket but apparently not in a way that it can be re-used as argument to NeoNode.connect_to(socket=<arg>)

This throws: A Stream Socket was expected, got <class \'mocket.mocket.MocketSocket\'>

            with Mocketizer():
                sock = socket.socket
                sock._address = (host, port) # fix socket.getbyhostname()
                n, reason = await node.NeoNode.connect_to(socket=sock)

This fails in mockets true_sendall()

            with Mocketizer():
                sock = mocket.MocketSocket()
                sock._address = (host, port) # fix socket.getbyhostname()
                n, reason = await node.NeoNode.connect_to(socket=sock)

the error

Traceback (most recent call last):
  File "/home/erik/neo-mamba/venv39/lib/python3.9/site-packages/mocket/mocket.py", line 340, in true_sendall
    encoded_response = hexload(response_dict["response"])
KeyError: 'response'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 918, in write
    n = self._sock.send(data)
  File "/home/erik/neo-mamba/venv39/lib/python3.9/site-packages/mocket/mocket.py", line 392, in send
    self.sendall(data, entry=entry, *args, **kwargs)
  File "/home/erik/neo-mamba/venv39/lib/python3.9/site-packages/mocket/mocket.py", line 270, in sendall
    response = self.true_sendall(data, *args, **kwargs)
  File "/home/erik/neo-mamba/venv39/lib/python3.9/site-packages/mocket/mocket.py", line 343, in true_sendall
    host, port = Mocket._address
AttributeError: type object 'Mocket' has no attribute '_address'

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

Successfully merging a pull request may close this issue.

1 participant