Skip to content

Commit

Permalink
fix tests by resetting default attributes for elements
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Jul 18, 2024
1 parent cec1b5d commit d6c31c7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion nicegui/testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import shutil
from pathlib import Path
from typing import AsyncGenerator, Callable, Dict, Generator
from typing import AsyncGenerator, Callable, Dict, Generator, List, Type

import httpx
import icecream
Expand Down Expand Up @@ -74,6 +74,14 @@ def nicegui_reset_globals() -> Generator[None, None, None]:
app.routes.remove(route)
importlib.reload(core)
importlib.reload(run)
element_classes: List[Type[ui.element]] = [ui.element]
while element_classes:
parent = element_classes.pop()
for cls in parent.__subclasses__():
cls._default_props = {} # pylint: disable=protected-access
cls._default_style = {} # pylint: disable=protected-access
cls._default_classes = [] # pylint: disable=protected-access
element_classes.append(cls)
Client.instances.clear()
Client.page_routes.clear()
app.reset()
Expand Down

0 comments on commit d6c31c7

Please sign in to comment.