def test_wr_output_echo(self): instr = b'\x00 \t\nabc123\x80\xff' wr(instr) res = self.server.recv(len(instr)) output = strip_ansi(self.stdout.read()) self.assertEqual(instr, res) self.assertEqual(output, '\\x00 \\x09\nabc123\\x80\\xff')
def test_wr_output_echo_noescape(self): self.sock.escape = False instr = b'\x00 \t\nabc123\x80\xff' wr(instr) res = self.server.recv(len(instr)) output = strip_ansi(self.stdout.read()) self.assertEqual(res, instr) self.assertEqual(output, _bytes_to_text(instr))
def test_wr_types(self): wr(b'1234') self.assertServerRecv(b'1234') wr(bytearray(b'1234')) self.assertServerRecv(b'1234') wr(1234) self.assertServerRecv(b'1234') wr("1234") self.assertServerRecv(b'1234') wr((1, )) self.assertServerRecv(b'(1,)')
def test_wr_types(self): wr(b'1234') self.assertServerRecv(b'1234') wr(bytearray(b'1234')) self.assertServerRecv(b'1234') wr(1234) self.assertServerRecv(b'1234') wr("1234") self.assertServerRecv(b'1234') wr((1,)) self.assertServerRecv(b'(1,)')
def test_wr_output_noecho(self): self.sock.echo = False instr = b'\x00 \t\nabc123\x80\xff' wr(instr) res = self.server.recv(len(instr)) # ensure stdout isn't empty (since self.stdout is nonblocking) sys.stdout.write('x') sys.stdout.flush() output = self.stdout.read() self.assertEqual(res, instr) # check that there was no output besides the character we stuffed in self.assertEqual(output, 'x')