File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 11import asyncio
22from typing import List , Optional
33
4+ import httpx
45import pytest
56
67from nicegui import PageArguments , background_tasks , ui
@@ -1087,6 +1088,24 @@ def main():
10871088
10881089 screen .open ('/bad_path' )
10891090 screen .should_contain ('HTTPException: 404: /bad_path not found' )
1091+ assert httpx .get (f'http://localhost:{ Screen .PORT } /bad_path' ).status_code == 404
1092+
1093+
1094+ def test_http_404_on_initial_request_with_async_page_builder (screen : Screen ):
1095+ @ui .page ('/' )
1096+ @ui .page ('/{_:path}' )
1097+ async def index ():
1098+ ui .sub_pages ({
1099+ '/' : main ,
1100+ })
1101+
1102+ def main ():
1103+ ui .label ('main page' )
1104+
1105+ screen .open ('/bad_path' )
1106+ # NOTE: due to the async page builder, sub pages can not determine 404 status on initial request (see https://github.com/zauberzeug/nicegui/pull/5089)
1107+ screen .should_contain ('404: sub page /bad_path not found' )
1108+ assert httpx .get (f'http://localhost:{ Screen .PORT } /bad_path' ).status_code == 200
10901109
10911110
10921111def test_clearing_sub_pages_element (screen : Screen ):
You can’t perform that action at this time.
0 commit comments