def __init__(self, *args, **kwargs): Stream.__init__(self, *args, **kwargs) # Request State Storage self.current_request = None self._finished = False # Read the initial request. self._await_request()
def test_stream_set_read_delimiter_invalid_value(self): # not a great test, given that the error needs to be raised # with any non-valid type, not just with a list stream = Stream() passed = False try: stream.read_delimiter = [] except TypeError: passed = True self.assertTrue(passed)
def __init__(self, encoding='utf-8', **kwargs): Stream.__init__(self, **kwargs) # Set our prefix to an empty string. This is prepended to all sent # commands, and useful for servers. self.prefix = '' self.encoding = encoding # Read lines at once. self.read_delimiter = '\n'
def connect(self, server=None, port=None): """ Connect to the server. ========= ============ Argument Description ========= ============ server The host to connect to. port The port to connect to on the remote server. ========= ============ """ if not self.connected and not self.connecting: if server: self._server = server if port: self._port = port Stream.connect(self, (self._server, self._port))
def connect(self, addr): """ Connect the channel to a remote Unix socket. Returns the channel. ========== ============ Arguments Description ========== ============ addr The address to connect to. ========== ============ """ return Stream.connect(self, addr)
def connect(self, host, port): """ Connect the channel to a remote socket. Returns the channel. ========== ============ Arguments Description ========== ============ host The remote host to connect to. port The port to connect on. ========== ============ """ return Stream.connect(self, (host, port))
def test_stream_handle_read_event_processes_recv_buffer_before_closing( self): # to ensure we don't reintroduce issue #41 stream = Stream() stream._socket_recv = MagicMock(return_value=None) manager = MagicMock() stream._process_recv_buffer = manager._process_recv_buffer stream.close = manager.close stream._handle_read_event() expected_calls = [call._process_recv_buffer(), call.close(flush=False)] self.assertTrue(manager.mock_calls == expected_calls)
def test_stream_handle_read_event_processes_recv_buffer_before_closing(self): # to ensure we don't reintroduce issue #41 stream = Stream() stream._socket_recv = MagicMock(return_value=None) manager = MagicMock() stream._process_recv_buffer = manager._process_recv_buffer stream.close = manager.close stream._handle_read_event() expected_calls = [call._process_recv_buffer(), call.close(flush=False)] self.assertTrue(manager.mock_calls == expected_calls)
def __init__(self, resolver, id, **kwargs): Stream.__init__(self, **kwargs) self.resolver = resolver self.id = id self.response = ""
def __init__(self, socket, server): Stream.__init__(self, socket=socket) self.server = server
def __init__(self): # This dummy method prevents keyword arguments from finding # their way up to the Stream/_Channel constructors. Stream.__init__(self, family=socket.AF_UNIX)
def __init__(self, resolver, id, **kwargs): Stream.__init__(self, **kwargs) self.resolver = resolver self.id = id self.response = ''