File: _debugger_case_gui_event_loop_qt5.py

package info (click to toggle)
pydevd 3.3.0%2Bds-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 13,892 kB
  • sloc: python: 77,508; cpp: 1,869; sh: 368; makefile: 50; ansic: 4
file content (51 lines) | stat: -rw-r--r-- 1,301 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
def call_method():

    from _pydevd_bundle.pydevd_constants import get_global_debugger
    py_db = get_global_debugger()

    # Check state prior to breaking
    assert not py_db.gui_in_use
    assert py_db._installed_gui_support
    assert py_db._gui_event_loop == 'qt5'

    import  os
    import PySide2
    from PySide2.QtCore import QTimer

    dirname = os.path.dirname(PySide2.__file__)
    plugin_path = os.path.join(dirname, 'plugins', 'platforms')
    if os.path.exists(plugin_path):
        os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

    from PySide2 import QtWidgets

    app = QtWidgets.QApplication([])

    def on_timeout():
        print('on_timeout() called')

    print_timer = QTimer()
    print_timer.timeout.connect(on_timeout)
    print_timer.setInterval(100)
    print_timer.start()

    def on_break():
        print('break here')
        app.quit()

    break_on_timer = QTimer()
    break_on_timer.timeout.connect(on_break)
    break_on_timer.setSingleShot(True)
    break_on_timer.setInterval(50)
    break_on_timer.start()

    app.exec_()  # Run forever until app.quit()

    assert py_db.gui_in_use
    assert py_db._installed_gui_support
    assert py_db._gui_event_loop == 'qt5'


if __name__ == '__main__':
    call_method()
    print('TEST SUCEEDED!')