Skip to content

Commit 2b85cac

Browse files
committed
Refactor offscreen detection function and update related logic in configuration tests
1 parent 21add48 commit 2b85cac

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

datalab/tests/backbone/config_unit_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ def is_wsl() -> bool:
9090
return False
9191

9292

93-
def is_offscreen_on_windows() -> bool:
94-
"""Return True if running in offscreen mode on Windows"""
95-
return os.environ.get("QT_QPA_PLATFORM", "") == "offscreen" and os.name == "nt"
93+
def is_offscreen() -> bool:
94+
"""Return True if running in offscreen mode (e.g. in CI or pytest session)"""
95+
return os.environ.get("QT_QPA_PLATFORM", "") == "offscreen"
9696

9797

9898
def assert_in_interval(val1, val2, interval, context):
@@ -101,10 +101,10 @@ def assert_in_interval(val1, val2, interval, context):
101101
try:
102102
assert itv1 <= val1 <= itv2
103103
except AssertionError as exc:
104-
if is_wsl() or is_offscreen_on_windows():
104+
if is_wsl() or is_offscreen():
105105
# Ignore this assertion error in two cases:
106106
# 1. If running on WSL, as the position of windows is not reliable
107-
# 2. If running in offscreen mode on Windows (e.g. in CI or pytest session),
107+
# 2. If running in offscreen mode (e.g. in CI or pytest session),
108108
# as the position of windows may not be set correctly in offscreen mode
109109
pass
110110
else:

0 commit comments

Comments
 (0)