diff --git a/uwsift/__main__.py b/uwsift/__main__.py
index 3bbc81be26c19c508c25356dcee98392b0fbd450..a8b72d728597727d2290fbd387594eb18159760b 100644
--- a/uwsift/__main__.py
+++ b/uwsift/__main__.py
@@ -1128,6 +1128,15 @@ def _search_paths(arglist):
             yield subpath
 
 
+def create_app() -> (app.Application, QtWidgets.QApplication):
+    QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
+    vispy_app = app.use_app('pyqt5')
+    qt_app = vispy_app.create()
+    if hasattr(QtWidgets.QStyleFactory, 'AA_UseHighDpiPixmaps'):
+        qt_app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
+    return vispy_app, qt_app
+
+
 def main():
     import argparse
     parser = argparse.ArgumentParser(description="Run SIFT")
@@ -1171,11 +1180,7 @@ def main():
 
     LOG.info("Using configuration directory: %s", args.config_dir)
     LOG.info("Using cache directory: %s", args.cache_dir)
-    QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
-    vispy_app = app.use_app('pyqt5')
-    qt_app = vispy_app.create()
-    if hasattr(QtWidgets.QStyleFactory, 'AA_UseHighDpiPixmaps'):
-        qt_app.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)
+    vispy_app, qt_app = create_app()
 
     # Add our own fonts to Qt windowing system
     font_pattern = os.path.join(get_package_data_dir(), 'fonts', '*')
diff --git a/uwsift/tests/conftest.py b/uwsift/tests/conftest.py
index e9d13ab6e74612a4bb5ae9c1e6d5028e3011adda..b66f1efb7a0a0e06ff0bfed6f1f0c10e8b277abd 100644
--- a/uwsift/tests/conftest.py
+++ b/uwsift/tests/conftest.py
@@ -1,5 +1,5 @@
 import pytest
-from uwsift.__main__ import Main
+from uwsift.__main__ import Main, create_app
 from uwsift.util.default_paths import USER_CONFIG_DIR
 from PyQt5.QtTest import QTest
 
@@ -7,6 +7,7 @@ from PyQt5.QtTest import QTest
 @pytest.fixture(scope="session")
 def window(tmp_path_factory):
     """Provides the SIFT GUI to tests."""
+    vispy_app, qt_app = create_app()  # noqa
     d = tmp_path_factory.mktemp("tmp")
     window = Main(config_dir=USER_CONFIG_DIR, workspace_dir=str(d))
     window.show()