Skip to content

Commit 4c9975a

Browse files
committed
App: Set app and monospace interface fonts when running single tests
That avoids a ton of Qt warnings to be displayed.
1 parent e932b7f commit 4c9975a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

spyder/app/utils.py

+18-2
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,24 @@ def create_application():
275275
# The try/except is necessary to run the main window tests on their own.
276276
try:
277277
app.set_font()
278-
except AttributeError:
279-
pass
278+
except AttributeError as error:
279+
if running_under_pytest():
280+
# Set font options to avoid a ton of Qt warnings when running the
281+
# tests.
282+
283+
# Set app font
284+
app_family = app.font().family()
285+
app_size = app.font().pointSize()
286+
CONF.set('appearance', 'app_font/family', app_family)
287+
CONF.set('appearance', 'app_font/size', app_size)
288+
289+
# Set monospace interface font
290+
from spyder.config.fonts import MEDIUM, MONOSPACE
291+
CONF.set('appearance', 'monospace_app_font/family', MONOSPACE[0])
292+
CONF.set('appearance', 'monospace_app_font/size', MEDIUM)
293+
else:
294+
# Raise in case the error is valid
295+
raise error
280296

281297
# Required for correct icon on GNOME/Wayland:
282298
if hasattr(app, 'setDesktopFileName'):

0 commit comments

Comments
 (0)