Test that we can index into a state var with another var.
()
| 476 | |
| 477 | |
| 478 | def 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 | |
| 499 | def test_class_attributes(): |