Przeglądaj źródła

testing exception logging in_on_page_ready event

Rodja Trappe 2 lat temu
rodzic
commit
9f31ac4a7e
1 zmienionych plików z 13 dodań i 0 usunięć
  1. 13 0
      tests/test_pages.py

+ 13 - 0
tests/test_pages.py

@@ -256,3 +256,16 @@ def test_exception_after_yield_on_async_page(screen: Screen):
     screen.open('/')
     screen.should_contain('this is shown')
     screen.assert_py_logger('ERROR', 'Failed to execute page-ready')
+
+
+def test_exception_in_on_page_ready_callback(screen: Screen):
+    def ready():
+        raise Exception('some exception')
+
+    @ui.page('/', on_page_ready=ready)
+    async def page() -> None:
+        ui.label('this is shown')
+
+    screen.open('/')
+    screen.should_contain('this is shown')
+    screen.assert_py_logger('ERROR', 'Failed to execute page-ready')