Skip to content

Commit

Permalink
App: Set app and monospace interface fonts when running single tests
Browse files Browse the repository at this point in the history
That avoids a ton of Qt warnings to be displayed.
  • Loading branch information
ccordoba12 committed Aug 20, 2023
1 parent e932b7f commit 4c9975a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions spyder/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,24 @@ def create_application():
# The try/except is necessary to run the main window tests on their own.
try:
app.set_font()
except AttributeError:
pass
except AttributeError as error:
if running_under_pytest():
# Set font options to avoid a ton of Qt warnings when running the
# tests.

# Set app font
app_family = app.font().family()
app_size = app.font().pointSize()
CONF.set('appearance', 'app_font/family', app_family)
CONF.set('appearance', 'app_font/size', app_size)

# Set monospace interface font
from spyder.config.fonts import MEDIUM, MONOSPACE
CONF.set('appearance', 'monospace_app_font/family', MONOSPACE[0])
CONF.set('appearance', 'monospace_app_font/size', MEDIUM)
else:
# Raise in case the error is valid
raise error

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

0 comments on commit 4c9975a

Please sign in to comment.