File: test_pydevd_api.py

package info (click to toggle)
pydevd 2.9.5%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,880 kB
  • sloc: python: 75,138; cpp: 1,851; sh: 310; makefile: 40; ansic: 4
file content (43 lines) | stat: -rw-r--r-- 1,404 bytes parent folder | download
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
import pytest
import sys


@pytest.mark.skipif(sys.platform != 'win32', reason='Windows-only test.')
def test_pydevd_api_breakpoints(tmpdir):
    from _pydevd_bundle.pydevd_api import PyDevdAPI
    from pydevd import PyDB
    import pydevd_file_utils
    api = PyDevdAPI()

    py_db = PyDB(set_as_global=False)

    dira = tmpdir.join('DirA')
    dira.mkdir()

    f = dira.join('filE.py')
    f.write_text('''
a = 1
b = 2
c = 3
''', 'utf-8')
    filename = str(f)

    result = api.add_breakpoint(
        py_db, filename, breakpoint_type='python-line', breakpoint_id=0, line=1, condition=None, func_name='None',
        expression=None, suspend_policy="NONE", hit_condition='', is_logpoint=False)
    assert not result.error_code

    result = api.add_breakpoint(
        py_db, filename, breakpoint_type='python-line', breakpoint_id=1, line=2, condition=None, func_name='None',
        expression=None, suspend_policy="NONE", hit_condition='', is_logpoint=False)
    assert not result.error_code

    canonical_path = pydevd_file_utils.canonical_normalized_path(filename)

    assert len(py_db.breakpoints[canonical_path]) == 2
    assert len(py_db.file_to_id_to_line_breakpoint[canonical_path]) == 2

    filename_replaced = filename.replace('DirA', 'dira')
    api.remove_all_breakpoints(py_db, filename_replaced)
    assert not py_db.breakpoints
    assert not py_db.file_to_id_to_line_breakpoint