File: _debugger_case_source_mapping_and_reference.py

package info (click to toggle)
pydevd 3.4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,892 kB
  • sloc: python: 77,580; cpp: 1,873; sh: 374; makefile: 50; ansic: 4
file content (57 lines) | stat: -rw-r--r-- 1,302 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def full_function():
    # Note that this function is not called, it's there just to make the mapping explicit.
    a = 1  # map to cEll1, line 2
    b = 2  # map to cEll1, line 3

    c = 3  # map to cEll2, line 2
    d = 4  # map to cEll2, line 3


def create_code():
    cell1_code = compile(''' # line 1
a = 1  # line 2
b = 2  # line 3
''', '<cEll1>', 'exec')

    cell2_code = compile('''# line 1
c = 3  # line 2
d = 4  # line 3
''', '<cEll2>', 'exec')

    # Set up the source in linecache. Python doesn't have a public API for
    # this, so we have to hack around it, similar to what IPython does.
    import linecache
    import time
    code = ''' # line 1
a = 1  # line 2
b = 2  # line 3
'''
    linecache.cache['<cEll1>'] = (
        len(code),
        time.time(),
        [line + '\n' for line in code.splitlines()],
        '<cEll1>',
    )

    code = '''# line 1
c = 3  # line 2
d = 4  # line 3
'''
    linecache.cache['<cEll2>'] = (
        len(code),
        time.time(),
        [line + '\n' for line in code.splitlines()],
        '<cEll2>',
    )

    return {'cEll1': cell1_code, 'cEll2': cell2_code}


if __name__ == '__main__':
    code = create_code()
    exec(code['cEll1'])
    exec(code['cEll1'])

    exec(code['cEll2'])
    exec(code['cEll2'])
    print('TEST SUCEEDED')