+ If you see this, it is all working. The Qt app should automatically close after a second.
+
+
diff --git a/tests/qtapp/solara-qt-test.py b/tests/qtapp/solara-qt-test.py
new file mode 100644
index 000000000..25d4fcb4b
--- /dev/null
+++ b/tests/qtapp/solara-qt-test.py
@@ -0,0 +1,68 @@
+import sys
+import threading
+from time import sleep
+from pathlib import Path
+
+import click
+import os
+
+# make sure you use pyside when distributing your app without having to use a GPL license
+from qtpy.QtWidgets import QApplication
+from qtpy.QtWebEngineWidgets import QWebEngineView
+from qtpy import QtCore
+
+
+HERE = Path(__file__).parent
+
+
+@click.command()
+@click.option(
+ "--port",
+ default=int(os.environ.get("PORT", 0)),
+ help="Port to run the server on, 0 for a random free port",
+)
+def run(port: int):
+ sys.path.append(str(HERE))
+ os.environ["SOLARA_APP"] = "test_app"
+ import test_app
+
+ import solara.server.starlette
+
+ server = solara.server.starlette.ServerStarlette(host="localhost", port=port)
+ print(f"Starting server on {server.base_url}")
+ server.serve_threaded()
+ server.wait_until_serving()
+
+ def test_success(value):
+ print("test output", value)
+ # calling app.quit seems to fail on windows and linux
+ # possibly because we are in a non-qt-thread (solara)
+ # app.quit()
+ QtCore.QMetaObject.invokeMethod(app, "quit", QtCore.Qt.QueuedConnection)
+ server.stop_serving()
+
+ test_app.callback = test_success # type: ignore
+
+ failed = False
+
+ def fail_guard():
+ sleep(10)
+ nonlocal failed
+ print("failed")
+ # similar as above
+ QtCore.QMetaObject.invokeMethod(app, "quit", QtCore.Qt.QueuedConnection)
+ failed = True
+
+ app = QApplication([""])
+ web = QWebEngineView()
+ web.setUrl(QtCore.QUrl(server.base_url))
+ web.show()
+
+ threading.Thread(target=fail_guard, daemon=True).start()
+ app.exec_()
+ if failed:
+ sys.exit(1)
+
+
+if __name__ == "__main__":
+ run()
diff --git a/tests/qtapp/test_app.py b/tests/qtapp/test_app.py
new file mode 100644
index 000000000..2c3020e48
--- /dev/null
+++ b/tests/qtapp/test_app.py
@@ -0,0 +1,18 @@
+import solara
+import solara.lab
+
+
+def callback(event):
+ print("Event received:", event)
+
+
+@solara.component_vue("render_test.vue")
+def RenderTest(event_rendered):
+ pass
+
+
+@solara.component
+def Page():
+ RenderTest(event_rendered=callback)
+ # make sure vue components of solara are working
+ solara.lab.ThemeToggle()
diff --git a/tests/unit/file_browser_test.py b/tests/unit/file_browser_test.py
index 4314842e2..98927da15 100644
--- a/tests/unit/file_browser_test.py
+++ b/tests/unit/file_browser_test.py
@@ -179,7 +179,7 @@ def Test():
list: solara.components.file_browser.FileListWidget = div.children[1]
items = list.files
names = {k["name"] for k in items}
- assert names == {"unit", "ui", "docs", "integration", "pyinstaller", ".."}
+ assert names == {"unit", "ui", "docs", "integration", "pyinstaller", "qtapp", ".."}
def test_file_browser_test_change_directory():
@@ -212,11 +212,11 @@ def set_directory(path: Path) -> None:
file_list.observe(mock, "files")
items = file_list.files
names = {k["name"] for k in items}
- assert names == {"unit", "ui", "docs", "integration", "pyinstaller", ".."}
+ assert names == {"unit", "ui", "docs", "integration", "pyinstaller", "qtapp", ".."}
file_list.test_click("..")
assert mock.call_count == 0
file_list.test_click("integration")
items = file_list.files
names = {k["name"] for k in items}
- assert names != {"unit", "ui", "docs", "integration", "pyinstaller", ".."}
+ assert names != {"unit", "ui", "docs", "integration", "pyinstaller", "qtapp", ".."}
assert mock.call_count == 1