add simple test that minified state names are unique
This commit is contained in:
parent
51aef9fd22
commit
7bf15b4f44
@ -286,7 +286,7 @@ def get_var_for_field(cls: Type[BaseState], f: ModelField):
|
||||
|
||||
|
||||
# Keep track of all state instances to calculate minified state names
|
||||
state_count = 0
|
||||
state_count: int = 0
|
||||
|
||||
all_state_names: Set[str] = set()
|
||||
|
||||
|
17
tests/test_minify_state.py
Normal file
17
tests/test_minify_state.py
Normal file
@ -0,0 +1,17 @@
|
||||
from typing import Set
|
||||
|
||||
from reflex.state import all_state_names, next_minified_state_name
|
||||
|
||||
|
||||
def test_next_minified_state_name():
|
||||
"""Test that the next_minified_state_name function returns unique state names."""
|
||||
current_state_count = len(all_state_names)
|
||||
state_names: Set[str] = set()
|
||||
gen: int = 10000
|
||||
for _ in range(gen):
|
||||
state_name = next_minified_state_name()
|
||||
assert state_name not in state_names
|
||||
state_names.add(state_name)
|
||||
assert len(state_names) == gen
|
||||
|
||||
assert len(all_state_names) == current_state_count + gen
|
Loading…
Reference in New Issue
Block a user