Code Duplication    Length = 18-20 lines in 2 locations

tests/test_remote_pdb.py 2 locations

@@ 36-55 (lines=20) @@
33
            wait_for_strings(proc.read, TIMEOUT, 'DIED.')
34
35
36
def test_redirect():
37
    with TestProcess(sys.executable, __file__, 'daemon', 'test_redirect') as proc:
38
        with dump_on_error(proc.read):
39
            wait_for_strings(proc.read, TIMEOUT,
40
                             '{a1}',
41
                             '{b1}',
42
                             'RemotePdb session open at ')
43
            host, port = re.findall("RemotePdb session open at (.+):(.+),", proc.read())[0]
44
            with TestSocket(socket.create_connection((host, int(port)), timeout=TIMEOUT)) as client:
45
                with dump_on_error(client.read):
46
                    wait_for_strings(proc.read, TIMEOUT, 'accepted connection from')
47
                    wait_for_strings(client.read, TIMEOUT, "-> print('{b2}')")
48
                    client.fh.write(b'break func_a\r\n')
49
                    client.fh.write(b'continue\r\n')
50
                    wait_for_strings(client.read, TIMEOUT, 'Breakpoint', '{b2}')
51
                    wait_for_strings(client.read, TIMEOUT, "-> print('{a2}')")
52
                    client.fh.write(b'continue\r\n')
53
                    wait_for_strings(client.read, TIMEOUT, "{=>")
54
            wait_for_strings(proc.read, TIMEOUT, 'DIED.')
55
            assert 'Restoring streams' not in proc.read()
56
57
58
def test_simple_break():
@@ 58-75 (lines=18) @@
55
            assert 'Restoring streams' not in proc.read()
56
57
58
def test_simple_break():
59
    with TestProcess(sys.executable, __file__, 'daemon', 'test_simple') as proc:
60
        with dump_on_error(proc.read):
61
            wait_for_strings(proc.read, TIMEOUT,
62
                             '{a1}',
63
                             '{b1}',
64
                             'RemotePdb session open at ')
65
            host, port = re.findall("RemotePdb session open at (.+):(.+),", proc.read())[0]
66
            with TestSocket(socket.create_connection((host, int(port)), timeout=TIMEOUT)) as client:
67
                with dump_on_error(client.read):
68
                    wait_for_strings(proc.read, TIMEOUT, 'accepted connection from')
69
                    wait_for_strings(client.read, TIMEOUT, "-> print('{b2}')")
70
                    client.fh.write(b'break func_a\r\n')
71
                    client.fh.write(b'continue\r\n')
72
                    wait_for_strings(client.read, TIMEOUT, "-> print('{a2}')")
73
                    client.fh.write(b'continue\r\n')
74
            wait_for_strings(proc.read, TIMEOUT, 'DIED.')
75
            assert 'Restoring streams' not in proc.read()
76
77
78
def func_b(patch_stdstreams):