示例#1
0
 def test_delimiter(self):
     """
     The delimiter can be whatever you want it to be.
     """
     transport = BoringTransport(["helloxtharx", "yesx"])
     wrapper = LineBuffer(transport, delimiter="x")
     self.assertEquals(wrapper.readLine(), "hello")
     self.assertEquals(wrapper.readLine(), "thar")
     self.assertEquals(wrapper.readLine(), "yes")
示例#2
0
 def test_delimiter(self):
     """
     The delimiter can be whatever you want it to be.
     """
     transport = BoringTransport(["helloxtharx", "yesx"])
     wrapper = LineBuffer(transport, delimiter="x")
     self.assertEquals(wrapper.readLine(), "hello")
     self.assertEquals(wrapper.readLine(), "thar")
     self.assertEquals(wrapper.readLine(), "yes")
示例#3
0
 def test_multipleLinesInOnePacket(self):
     """
     C{readLine} handles multiple lines in one C{transport.read} result by
     only returning the first and saving the rest for the next call.
     """
     transport = BoringTransport(["foo\r\nbar\r\nbaz\r\n", "quux\r\n"])
     wrapper = LineBuffer(transport)
     self.assertEquals(wrapper.readLine(), "foo")
     self.assertEquals(wrapper.readLine(), "bar")
     self.assertEquals(wrapper.readLine(), "baz")
     self.assertEquals(wrapper.readLine(), "quux")
示例#4
0
 def test_multipleLinesInOnePacket(self):
     """
     C{readLine} handles multiple lines in one C{transport.read} result by
     only returning the first and saving the rest for the next call.
     """
     transport = BoringTransport(["foo\r\nbar\r\nbaz\r\n", "quux\r\n"])
     wrapper = LineBuffer(transport)
     self.assertEquals(wrapper.readLine(), "foo")
     self.assertEquals(wrapper.readLine(), "bar")
     self.assertEquals(wrapper.readLine(), "baz")
     self.assertEquals(wrapper.readLine(), "quux")
示例#5
0
 def test_truncateDelimiter(self):
     """
     C{readLine} returns a full line without delimiter.
     """
     io = StringIO("Hello world\r\n")
     wrapper = LineBuffer(io)
     self.assertEquals(wrapper.readLine(), "Hello world")
示例#6
0
 def test_truncateDelimiter(self):
     """
     C{readLine} returns a full line without delimiter.
     """
     io = StringIO("Hello world\r\n")
     wrapper = LineBuffer(io)
     self.assertEquals(wrapper.readLine(), "Hello world")
示例#7
0
 def test_multipleLines(self):
     """
     Each call to C{readLine} returns the next line received.
     """
     transport = BoringTransport(["a\r\n", "b\r\n"])
     wrapper = LineBuffer(transport)
     self.assertEquals(wrapper.readLine(), "a")
     self.assertEquals(wrapper.readLine(), "b")
示例#8
0
 def test_buffer(self):
     """
     If C{readLine} cannot immediately get a full line from
     C{transport.read}, it will buffer that data until the next read.
     """
     transport = BoringTransport(["a", "b\r\n"])
     wrapper = LineBuffer(transport)
     self.assertEquals(wrapper.readLine(), "ab")
示例#9
0
 def test_multipleLines(self):
     """
     Each call to C{readLine} returns the next line received.
     """
     transport = BoringTransport(["a\r\n", "b\r\n"])
     wrapper = LineBuffer(transport)
     self.assertEquals(wrapper.readLine(), "a")
     self.assertEquals(wrapper.readLine(), "b")
示例#10
0
 def test_buffer(self):
     """
     If C{readLine} cannot immediately get a full line from
     C{transport.read}, it will buffer that data until the next read.
     """
     transport = BoringTransport(["a", "b\r\n"])
     wrapper = LineBuffer(transport)
     self.assertEquals(wrapper.readLine(), "ab")