MCPcopy Index your code
hub / github.com/python/cpython / FakeSocket

Class FakeSocket

Lib/test/test_httplib.py:54–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52HOST = socket_helper.HOST
53
54class FakeSocket:
55 def __init__(self, text, fileclass=io.BytesIO, host=None, port=None):
56 if isinstance(text, str):
57 text = text.encode("ascii")
58 self.text = text
59 self.fileclass = fileclass
60 self.data = b''
61 self.sendall_calls = 0
62 self.file_closed = False
63 self.host = host
64 self.port = port
65
66 def sendall(self, data):
67 self.sendall_calls += 1
68 self.data += data
69
70 def makefile(self, mode, bufsize=None):
71 if mode != 'r' and mode != 'rb':
72 raise client.UnimplementedFileMode()
73 # keep the file around so we can check how much was read from it
74 self.file = self.fileclass(self.text)
75 self.file.close = self.file_close #nerf close ()
76 return self.file
77
78 def file_close(self):
79 self.file_closed = True
80
81 def close(self):
82 pass
83
84 def setsockopt(self, level, optname, value):
85 pass
86
87class EPipeSocket(FakeSocket):
88

Callers 15

test_entity_resolverMethod · 0.90
test_parse_uriMethod · 0.90
create_connectionMethod · 0.70
test_auto_headersMethod · 0.70
test_content_length_0Method · 0.70
test_putheaderMethod · 0.70
test_ipv6host_headerMethod · 0.70
test_parse_all_octetsMethod · 0.70
test_invalid_headersMethod · 0.70

Calls

no outgoing calls

Tested by 15

test_entity_resolverMethod · 0.72
test_parse_uriMethod · 0.72
create_connectionMethod · 0.56
test_auto_headersMethod · 0.56
test_content_length_0Method · 0.56
test_putheaderMethod · 0.56
test_ipv6host_headerMethod · 0.56
test_parse_all_octetsMethod · 0.56
test_invalid_headersMethod · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…