AppHarness: handle get_state_name
for minified names
Also clear the StatefulComponent cache between AppInstance runs
This commit is contained in:
parent
6eb808ca2c
commit
db2b5b0320
@ -43,6 +43,7 @@ import reflex.utils.exec
|
|||||||
import reflex.utils.format
|
import reflex.utils.format
|
||||||
import reflex.utils.prerequisites
|
import reflex.utils.prerequisites
|
||||||
import reflex.utils.processes
|
import reflex.utils.processes
|
||||||
|
from reflex.components.component import StatefulComponent
|
||||||
from reflex.config import environment
|
from reflex.config import environment
|
||||||
from reflex.state import (
|
from reflex.state import (
|
||||||
BaseState,
|
BaseState,
|
||||||
@ -51,6 +52,7 @@ from reflex.state import (
|
|||||||
StateManagerDisk,
|
StateManagerDisk,
|
||||||
StateManagerMemory,
|
StateManagerMemory,
|
||||||
StateManagerRedis,
|
StateManagerRedis,
|
||||||
|
minified_state_names,
|
||||||
reload_state_module,
|
reload_state_module,
|
||||||
)
|
)
|
||||||
from reflex.utils.types import override
|
from reflex.utils.types import override
|
||||||
@ -193,17 +195,13 @@ class AppHarness:
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The state name
|
The state name
|
||||||
|
|
||||||
Raises:
|
|
||||||
NotImplementedError: when minified state names are enabled
|
|
||||||
"""
|
"""
|
||||||
if reflex.constants.CompileVars.MINIFY_STATES():
|
state_name = reflex.utils.format.to_snake_case(
|
||||||
raise NotImplementedError(
|
|
||||||
"This API is not available with minified state names."
|
|
||||||
)
|
|
||||||
return reflex.utils.format.to_snake_case(
|
|
||||||
f"{self.app_name}___{self.app_name}___" + state_cls_name
|
f"{self.app_name}___{self.app_name}___" + state_cls_name
|
||||||
)
|
)
|
||||||
|
if reflex.constants.CompileVars.MINIFY_STATES():
|
||||||
|
return minified_state_names.get(state_name, state_name)
|
||||||
|
return state_name
|
||||||
|
|
||||||
def get_full_state_name(self, path: List[str]) -> str:
|
def get_full_state_name(self, path: List[str]) -> str:
|
||||||
"""Get the full state name for the given state class name.
|
"""Get the full state name for the given state class name.
|
||||||
@ -284,6 +282,8 @@ class AppHarness:
|
|||||||
)
|
)
|
||||||
self.app_module_path.write_text(source_code)
|
self.app_module_path.write_text(source_code)
|
||||||
with chdir(self.app_path):
|
with chdir(self.app_path):
|
||||||
|
# Reset stateful component cache for new app
|
||||||
|
StatefulComponent.tag_to_stateful_component.clear()
|
||||||
# ensure config and app are reloaded when testing different app
|
# ensure config and app are reloaded when testing different app
|
||||||
reflex.config.get_config(reload=True)
|
reflex.config.get_config(reload=True)
|
||||||
# Save decorated pages before importing the test app module
|
# Save decorated pages before importing the test app module
|
||||||
|
Loading…
Reference in New Issue
Block a user