Skip to content

Commit 1570947

Browse files
[TESTING] Imporved test coverage slightly (- WIP #53 -)
Changes in file multicast/recv.py: - added doctest to mock recieving input. recv now fully covered by tests.
1 parent 011d674 commit 1570947

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

multicast/recv.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,34 @@ def tryrecv(msgbuffer, chunk, sock):
341341
>>> sk_fxtr.close()
342342
>>>
343343
344+
Testcase 2: Mock overflow testing.
345+
346+
>>> import multicast
347+
>>>
348+
>>> multicast.recv is None
349+
False
350+
>>> multicast.recv.tryrecv is None
351+
False
352+
>>> type(multicast.recv.tryrecv) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
353+
<class 'function'>
354+
>>> class mockSocket():
355+
... def recv(self, *args, **kwargs):
356+
... return b'it worked'
357+
...
358+
... def close(self):
359+
... pass
360+
...
361+
... def shutdown(self, *args, **kwargs):
362+
... pass
363+
...
364+
>>>
365+
>>> sk_fxtr = mockSocket()
366+
>>> tst_args = ("test added: ", None, sk_fxtr)
367+
>>> multicast.recv.recvstep(*tst_args) #doctest: -DONT_ACCEPT_BLANKLINE, +ELLIPSIS
368+
'test added: it worked'
369+
>>> sk_fxtr.close()
370+
>>>
371+
344372
"""
345373
chunk = sock.recv(1316)
346374
if not (chunk is None): # pragma: no branch

0 commit comments

Comments
 (0)