def test_recv_piece(self):
     self.sock.recv(IsA(int)).AndReturn("one\r\ntwo")
     self.sock.recv(IsA(int)).AndReturn("\r\nthree\r\n.\r\nstuff\r\n")
     self.mox.ReplayAll()
     dr = DataReader(IO(self.sock))
     self.assertTrue(dr.recv_piece())
     self.assertFalse(dr.recv_piece())
     self.assertEqual(["one\r\n", "two\r\n", "three\r\n", ".\r\n", "stuff\r\n", ""], dr.lines)
     self.assertEqual(3, dr.EOD)
     self.assertEqual(5, dr.i)
 def test_recv_piece(self):
     self.sock.recv(IsA(int)).AndReturn(b'one\r\ntwo')
     self.sock.recv(IsA(int)).AndReturn(b'\r\nthree\r\n.\r\nstuff\r\n')
     self.mox.ReplayAll()
     dr = DataReader(IO(self.sock))
     self.assertTrue(dr.recv_piece())
     self.assertFalse(dr.recv_piece())
     self.assertEqual([b'one\r\n', b'two\r\n', b'three\r\n',
                       b'.\r\n', b'stuff\r\n', b''], dr.lines)
     self.assertEqual(3, dr.EOD)
     self.assertEqual(5, dr.i)
 def test_recv_piece(self):
     self.sock.recv(IsA(int)).AndReturn('one\r\ntwo')
     self.sock.recv(IsA(int)).AndReturn('\r\nthree\r\n.\r\nstuff\r\n')
     self.mox.ReplayAll()
     dr = DataReader(IO(self.sock))
     assert_true(dr.recv_piece())
     assert_false(dr.recv_piece())
     assert_equal(['one\r\n', 'two\r\n', 'three\r\n',
                       '.\r\n', 'stuff\r\n', ''], dr.lines)
     assert_equal(3, dr.EOD)
     assert_equal(5, dr.i)
 def test_recv_piece_already_eod(self):
     dr = DataReader(None)
     dr.EOD = 2
     self.assertFalse(dr.recv_piece())