Beispiel #1
0
    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')
Beispiel #2
0
    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')
Beispiel #3
0
    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))
Beispiel #4
0
    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))
Beispiel #5
0
    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,)')
Beispiel #6
0
    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,)')
Beispiel #7
0
    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')
Beispiel #8
0
    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')