forked from pyQode/pyqode.python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
74 lines (58 loc) · 1.65 KB
/
conftest.py
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
68
69
70
71
72
73
74
# -*- coding: utf-8 -*-
"""
This scripts configures the test suite. We do two things:
- setup the logging module
- create ONE SINGLE INSTANCE of QApplication:
this implies that you must use **QApplication.instance** in your
test scripts (or the app fixture).
"""
import logging
import sys
import pytest
from pyqode.qt.QtWidgets import QApplication
try:
import faulthandler
faulthandler.enable()
except ImportError:
pass
# -------------------
# Setup logging
# -------------------
logging.basicConfig(level=logging.DEBUG,
filename='pytest.log',
filemode='w')
# -------------------
# Setup QApplication
# -------------------
# 2. create qt application
_app = QApplication(sys.argv)
_widget = None
# -------------------
# Session fixtures
# -------------------
@pytest.fixture(scope="session")
def app(request):
global _app
return app
@pytest.fixture()
def editor(request):
global _app, _widget
from pyqode.core import modes, cache
from pyqode.python.widgets.code_edit import PyCodeEdit
from pyqode.python.panels import SymbolBrowserPanel
from pyqode.qt.QtTest import QTest
cache.Cache().clear()
_widget = PyCodeEdit()
_widget.panels.append(SymbolBrowserPanel(),
SymbolBrowserPanel.Position.TOP)
_widget.resize(800, 600)
while not _widget.backend.connected:
QTest.qWait(100)
_widget.modes.get(modes.FileWatcherMode).file_watcher_auto_reload = True
_widget.save_on_focus_out = False
def fin():
global _widget
_widget.close()
del _widget
request.addfinalizer(fin)
return _widget