Repository navigation
Expand file tree
/
Copy pathtest__shared.py
More file actions
77 lines (52 loc) · 1.5 KB
/
Copy pathtest__shared.py
File metadata and controls
77 lines (52 loc) · 1.5 KB
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
75
76
77
import os
from hackedit.api import _shared
from hackedit.app.main_window import MainWindow
from hackedit.plugins.workspaces import GenericWorkspace
import pytest_hackedit
DATA_FILES_PATH = os.path.join(os.getcwd(), 'tests', 'data')
PROJ_PATH = os.path.join(DATA_FILES_PATH, 'FooBarProj')
class NoWindow:
def get_window(self):
return _shared._window()
class NoneWindow:
def __init__(self):
self.main_window = None
def get_window(self):
return self._get()
def _get(self):
w = _shared._window()
return w
class WrongType:
def __init__(self):
self.main_window = 10
def get_window(self):
return self._get()
def _get(self):
w = _shared._window()
return w
class CorrectType:
def __init__(self):
self.main_window = MainWindow(pytest_hackedit.app(), PROJ_PATH,
GenericWorkspace.get_data())
def get_window(self):
return self._get()
def _get(self):
w = _shared._window()
return w
def test_no_window(qtbot):
pytest_hackedit.app()
assert NoWindow().get_window() is None
def test_none_window():
pytest_hackedit.app()
w = NoneWindow().get_window()
assert w is None
def test_wrong_type():
pytest_hackedit.app()
w = WrongType().get_window()
assert w is None
def test_correct_type():
pytest_hackedit.app()
w = CorrectType().get_window()
assert w is not None
assert isinstance(w, MainWindow)
w.close()