Skip to content

Commit 78a5035

Browse files
committed
fix broken tests
1 parent d76a0e7 commit 78a5035

File tree

3 files changed

+5
-22
lines changed

3 files changed

+5
-22
lines changed

nicegui/testing/general_fixtures.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,14 @@ def pytest_configure(config: pytest.Config) -> None:
2222
def nicegui_reset_globals() -> Generator[None, None, None]:
2323
"""Reset the global state of the NiceGUI package."""
2424
for route in list(app.routes):
25-
if isinstance(route, Route) and route.path.startswith('/_nicegui/auto/static/'):
26-
app.remove_route(route.path)
27-
28-
all_page_routes = set(Client.page_routes.values())
29-
all_page_routes.add('/')
30-
for path in all_page_routes:
31-
app.remove_route(path)
32-
33-
for route in list(app.routes):
34-
if (
35-
isinstance(route, Route) and
36-
'{' in route.path and '}' in route.path and
37-
not route.path.startswith('/_nicegui/')
38-
):
25+
if isinstance(route, Route) and (not route.path.startswith('/_nicegui/') or route.path.startswith('/_nicegui/auto/static')):
3926
app.remove_route(route.path)
4027

4128
app.openapi_schema = None
4229
app.middleware_stack = None
4330
app.user_middleware.clear()
4431
app.urls.clear()
4532
core.air = None
46-
# NOTE favicon routes must be removed separately because they are not "pages"
47-
for route in list(app.routes):
48-
if isinstance(route, Route) and route.path.endswith('/favicon.ico'):
49-
app.routes.remove(route)
5033
importlib.reload(core)
5134
importlib.reload(run)
5235

tests/test_interactive_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
@pytest.fixture(autouse=True)
14-
def provide_image_files():
14+
def provide_image_files(nicegui_reset_globals):
1515
app.add_static_file(local_file=Path(__file__).parent / 'media' / 'test1.jpg', url_path=URL_PATH1)
1616
app.add_static_file(local_file=Path(__file__).parent / 'media' / 'test2.jpg', url_path=URL_PATH2)
1717

tests/test_sub_pages.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,23 +526,23 @@ def sub_content():
526526

527527
screen.open('/foo/sub')
528528
screen.should_contain('sub-content')
529-
assert screen.current_path == '/foo/sub'
529+
assert screen.current_path.rstrip('/') == '/foo/sub'
530530

531531
screen.click('Go to main')
532532
screen.should_contain('main-content')
533533
assert screen.current_path == '/foo'
534534

535535
screen.click('Go to sub')
536536
screen.should_contain('sub-content')
537-
assert screen.current_path == '/foo/sub'
537+
assert screen.current_path.rstrip('/') == '/foo/sub'
538538

539539
screen.click('Go to main')
540540
screen.should_contain('main-content')
541541
assert screen.current_path == '/foo'
542542

543543
screen.click('Go to sub')
544544
screen.should_contain('sub-content')
545-
assert screen.current_path == '/foo/sub'
545+
assert screen.current_path.rstrip('/') == '/foo/sub'
546546

547547

548548
def test_links_pointing_to_path_which_is_not_a_sub_page(screen: Screen):

0 commit comments

Comments
 (0)