MCPcopy
hub / github.com/reflex-dev/reflex / test_class_indexing_with_vars

Function test_class_indexing_with_vars

tests/units/test_state.py:478–496  ·  view source on GitHub ↗

Test that we can index into a state var with another var.

()

Source from the content-addressed store, hash-verified

476
477
478def test_class_indexing_with_vars():
479 """Test that we can index into a state var with another var."""
480 prop = TestState.array[TestState.num1] # pyright: ignore [reportCallIssue, reportArgumentType]
481 assert (
482 str(prop)
483 == f"{TestState.get_name()}.array{FIELD_MARKER}?.at?.({TestState.get_name()}.num1{FIELD_MARKER})"
484 )
485
486 prop = TestState.mapping["a"][TestState.num1] # pyright: ignore [reportCallIssue, reportArgumentType]
487 assert (
488 str(prop)
489 == f'{TestState.get_name()}.mapping{FIELD_MARKER}?.["a"]?.at?.({TestState.get_name()}.num1{FIELD_MARKER})'
490 )
491
492 prop = TestState.mapping[TestState.map_key]
493 assert (
494 str(prop)
495 == f"{TestState.get_name()}.mapping{FIELD_MARKER}?.[{TestState.get_name()}.map_key{FIELD_MARKER}]"
496 )
497
498
499def test_class_attributes():

Callers

nothing calls this directly

Calls 1

get_nameMethod · 0.80

Tested by

no test coverage detected