File: tests-Allow-to-skip-interactive-tests-via-environ-variabl.patch

package info (click to toggle)
pystray 0.19.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 400 kB
  • sloc: python: 2,348; sh: 18; makefile: 13
file content (206 lines) | stat: -rw-r--r-- 6,652 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
From: Claudius Heine <ch@denx.de>
Date: Mon, 24 Oct 2022 10:33:30 +0200
Subject: tests: Allow one to skip interactive tests via environment variable

Interactive tests cannot be executed in automated test environments.

This adds a way to skip those tests via setting the `TEST_SKIP_INTERACTIVE`
variable to `1`.

[Upstream-Status: submitted(https://github.com/moses-palmer/pystray/pull/133)]
---
 tests/icon_tests.py | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tests/icon_tests.py b/tests/icon_tests.py
index 00522f1..848f1e5 100644
--- a/tests/icon_tests.py
+++ b/tests/icon_tests.py
@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
+import os
 import sys
 import unittest
 
@@ -107,7 +108,19 @@ def for_notification(test):
         return lambda *a: None
 
 
+def interactive_test(test):
+    """Marks a test as interactive, which prevents it from being run when environment
+    variable "TEST_SKIP_INTERACTIVE" is set to "1".
+    
+    :param test: The test.
+    """
+    return unittest.skipIf(
+            os.environ["TEST_SKIP_INTERACTIVE"] == "1",
+                "skip interactive test")
+
+
 class IconTest(unittest.TestCase):
+    @interactive_test
     def test_set_icon(self):
         """Tests that updating the icon works.
         """
@@ -126,6 +139,7 @@ class IconTest(unittest.TestCase):
                 self,
                 'Did an alternating %s, and %s icon appear?', colors1, colors2)
 
+    @interactive_test
     def test_set_icon_after_constructor(self):
         """Tests that updating the icon works.
         """
@@ -141,6 +155,7 @@ class IconTest(unittest.TestCase):
                 self,
                 'Did an icon appear?')
 
+    @interactive_test
     def test_set_icon_to_none(self):
         """Tests that setting the icon to None hides it.
         """
@@ -157,6 +172,7 @@ class IconTest(unittest.TestCase):
                 self,
                 'Did the %s icon disappear?', colors)
 
+    @interactive_test
     def test_title(self):
         """Tests that initialising with a title works.
         """
@@ -171,6 +187,7 @@ class IconTest(unittest.TestCase):
                 self,
                 'Did an %s icon with the title "%s" appear?', colors, title)
 
+    @interactive_test
     def test_title_set_hidden(self):
         """Tests that setting the title of a hidden icon works.
         """
@@ -186,6 +203,7 @@ class IconTest(unittest.TestCase):
                 self,
                 'Did a %s icon with the title "%s" appear?', colors, title)
 
+    @interactive_test
     def test_title_set_visible(self):
         """Tests that setting the title of a visible icon works.
         """
@@ -212,6 +230,7 @@ class IconTest(unittest.TestCase):
             ico.visible = True
             self.assertTrue(ico.visible)
 
+    @interactive_test
     def test_visible_set(self):
         """Tests that showing a simple icon works.
         """
@@ -238,6 +257,7 @@ class IconTest(unittest.TestCase):
             finally:
                 ico.visible = False
 
+    @interactive_test
     def test_show_hide(self):
         """Tests that showing and hiding the icon works.
         """
@@ -256,6 +276,7 @@ class IconTest(unittest.TestCase):
                 'Did a flashing %s icon appear?', colors)
 
     @for_default_action
+    @interactive_test
     def test_activate(self):
         """Tests that ``on_activate`` is correctly called.
         """
@@ -274,6 +295,7 @@ class IconTest(unittest.TestCase):
             say('Click the icon')
             q.get(timeout=TIMEOUT)
 
+    @interactive_test
     def test_activate_with_default(self):
         """Tests that the default menu item is activated when activating icon.
         """
@@ -294,6 +316,7 @@ class IconTest(unittest.TestCase):
             q.get(timeout=TIMEOUT)
 
     @for_menu
+    @interactive_test
     def test_menu_construct(self):
         """Tests that the menu is constructed.
         """
@@ -311,6 +334,7 @@ class IconTest(unittest.TestCase):
                 'Was it\n%s?' % str(ico.menu))
 
     @for_menu
+    @interactive_test
     def test_menu_activate(self):
         """Tests that the menu can be activated.
         """
@@ -331,6 +355,7 @@ class IconTest(unittest.TestCase):
             q.get(timeout=TIMEOUT)
 
     @for_menu
+    @interactive_test
     def test_menu_activate_method(self):
         """Tests that the menu can be activated and a method can be used.
         """
@@ -353,6 +378,7 @@ class IconTest(unittest.TestCase):
             q.get(timeout=TIMEOUT)
 
     @for_menu
+    @interactive_test
     def test_menu_activate_submenu(self):
         """Tests that an item in a submenu can be activated.
         """
@@ -375,6 +401,7 @@ class IconTest(unittest.TestCase):
             q.get(timeout=TIMEOUT)
 
     @for_default_action
+    @interactive_test
     def test_menu_invisble(self):
         """Tests that a menu consisting of only empty items does not show.
         """
@@ -395,6 +422,7 @@ class IconTest(unittest.TestCase):
             q.get(timeout=TIMEOUT)
 
     @for_menu
+    @interactive_test
     def test_menu_dynamic(self):
         """Tests that a dynamic menu works.
         """
@@ -424,6 +452,7 @@ class IconTest(unittest.TestCase):
 
     @for_default_action
     @for_menu
+    @interactive_test
     def test_menu_dynamic_show_hide(self):
         """Tests that a dynamic menu that is hidden works as expected.
         """
@@ -457,6 +486,7 @@ class IconTest(unittest.TestCase):
                 'Was it\n%s?' % str(ico.menu))
 
     @for_menu_radio
+    @interactive_test
     def test_menu_radio(self):
         """Tests that mutually exclusive items are displayed separately.
         """
@@ -474,6 +504,7 @@ class IconTest(unittest.TestCase):
                 'Was <Item 2> displayed differently from <Item 1>?')
 
     @for_menu_radio
+    @interactive_test
     def test_menu_enabled(self):
         """Tests that menu items can be disabled.
         """
@@ -491,6 +522,7 @@ class IconTest(unittest.TestCase):
                 'Was <Item 1> enabled and <Item 2> disabled?')
 
     @for_notification
+    @interactive_test
     def test_show_notification(self):
         """Tests that generation of a notification works.
         """
@@ -505,6 +537,7 @@ class IconTest(unittest.TestCase):
                 'Did a notification appear?')
 
     @for_notification
+    @interactive_test
     def test_hide_notification(self):
         """Tests that a notification can be removed again.
         """