-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
test_sidebardialog.py
79 lines (59 loc) · 1.97 KB
/
test_sidebardialog.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
75
76
77
78
79
# -*- coding: utf-8 -*-
#
# Copyright © Spyder Project Contributors
# Licensed under the terms of the MIT License
#
"""Tests for SidebarDialog."""
# Third party imports
from qtpy.QtWidgets import QLabel, QVBoxLayout
import pytest
# Local imports
from spyder.utils.stylesheet import APP_STYLESHEET
from spyder.widgets.sidebardialog import SidebarDialog, SidebarPage
# --- Fixtures
# -----------------------------------------------------------------------------
@pytest.fixture
def sidebar_dialog(qapp, qtbot):
# Pages
class Page1(SidebarPage):
def get_name(self):
return "Page 1"
def get_icon(self):
return self.create_icon("variable_explorer")
def setup_page(self):
self.label = QLabel("This is page one!")
layout = QVBoxLayout()
layout.addWidget(self.label)
layout.addStretch(1)
self.setLayout(layout)
class Page2(SidebarPage):
def get_name(self):
return "Page 2"
def get_icon(self):
return self.create_icon("files")
def setup_page(self):
self.label = QLabel("This is page two!")
layout = QVBoxLayout()
layout.addWidget(self.label)
layout.addStretch(1)
self.setLayout(layout)
# Dialog
class TestDialog(SidebarDialog):
PAGE_CLASSES = [Page1, Page2]
qapp.setStyleSheet(str(APP_STYLESHEET))
dialog = TestDialog()
qtbot.addWidget(dialog)
dialog.show()
return dialog
# --- Tests
# -----------------------------------------------------------------------------
def test_sidebardialog(sidebar_dialog, qtbot):
dialog = sidebar_dialog
assert dialog is not None
# To check the dialog visually
qtbot.wait(1000)
# Check label displayed in the initial page
assert "one" in dialog.get_page().label.text()
# Check label in the second page
dialog.set_current_index(1)
assert "two" in dialog.get_page().label.text()