Skip to content

Commit 8a6f706

Browse files
committed
fix(view): ask before asserting when no dialog backend exists
The two cases in MessageBoxTests that drive the button search asserted against whatever backend the session had. On the plain Ubuntu CI job there is no X display, so piny_view.backend() is None and the dispatcher answers None for a different reason -- the shape-rule case failed with "unexpectedly None" on a machine where the rule was never asked. Guard both: a session with no backend skips, saying so. Reproduced by running the suite with both available() predicates forced False, which is what that job sees: the first case fails, and with the guard the suite is OK (skipped=15). The second case expects None and got None either way, so its guard is not load-bearing; it is there so the pass cannot be earned by an absent backend.
1 parent 0a28638 commit 8a6f706

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎tests/test_view.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ def test_the_button_search_is_among_the_names_pushed_to_the_backend(self):
208208
self.assertTrue(set(v._FORWARDED) <= set(v._PUSH_ON_REPLACE))
209209

210210
def test_button_is_found_by_shape_in_the_bottom_band(self):
211+
# Needs a backend: the shape rule lives in each backend, and with none reachable (a Linux
212+
# runner with no DISPLAY, say) the dispatcher has nothing to ask and answers None -- which
213+
# the Ubuntu job reported as a failure in this test. Skipping is the honest outcome there;
214+
# the rule itself is exercised on Windows and in the X11 CI job.
215+
if v.backend() is None:
216+
self.skipTest('no dialog backend in this session to run the shape rule in')
211217
window = {'hwnd': 1, 'rect': (696, 289, 1214, 786)} # 518 x 497, measured
212218
children = [
213219
{'hwnd': 2, 'class': 'QWidget', 'text': '', 'rect': (709, 366, 1201, 725)}, # text area
@@ -257,6 +263,11 @@ def test_a_replaced_child_lookup_is_what_the_button_search_uses(self):
257263
self.assertEqual(button['rect'], [1108, 745, 1201, 773])
258264

259265
def test_no_button_child_reports_none_rather_than_guessing(self):
266+
# Not load-bearing -- this case expects None and gets None either way -- but without the
267+
# guard the pass would be earned by an absent backend rather than by the shape rule, and
268+
# that is the kind of green that hides a regression.
269+
if v.backend() is None:
270+
self.skipTest('no dialog backend in this session to run the shape rule in')
260271
window = {'hwnd': 1, 'rect': (100, 100, 400, 300)}
261272
saved = v.child_windows
262273
v.child_windows = lambda hwnd: [{'hwnd': 2, 'class': 'QWidget', 'text': '',

0 commit comments

Comments
 (0)