File size: 707 Bytes
065fee7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import socket
import typing


class MockSocket(socket.socket):
    mocked_data: typing.Optional[bytes] = None

    def __init__(self, family=-1, type=-1, proto=-1, fileno=None):
        pass

    def __exit__(self, exc_type, exc_val, exc_tb):
        pass

    def setsockopt(self, level, optname, value):
        pass

    def bind(self, address):
        pass

    def listen(self, __backlog=...):
        pass

    def settimeout(self, value):
        pass

    def accept(self):
        return (MockSocket(), "127.0.0.1")

    def recv(self, bufsize, flags=...):
        return self.mocked_data

    def close(self) -> None:
        pass

    def send(self, *args) -> None:  # type: ignore
        pass