File: test_pydevd_api.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 (67 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
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