Test the get_value method directly with various key types. Args: key_factory: Factory function to create the key for testing. expected_result: The expected return value from get_value. should_raise: Whether the test should expect a TypeError.
(key_factory, expected_result, should_raise)
| 4514 | ], |
| 4515 | ) |
| 4516 | def test_get_value(key_factory, expected_result, should_raise): |
| 4517 | """Test the get_value method directly with various key types. |
| 4518 | |
| 4519 | Args: |
| 4520 | key_factory: Factory function to create the key for testing. |
| 4521 | expected_result: The expected return value from get_value. |
| 4522 | should_raise: Whether the test should expect a TypeError. |
| 4523 | """ |
| 4524 | |
| 4525 | class GetValueState(rx.State): |
| 4526 | """Test state class for get_value testing.""" |
| 4527 | |
| 4528 | foo: str = "FOO" |
| 4529 | bar: str = "BAR" |
| 4530 | |
| 4531 | state = GetValueState() |
| 4532 | key = key_factory(state) |
| 4533 | |
| 4534 | if should_raise: |
| 4535 | with pytest.raises(TypeError, match="Invalid key type"): |
| 4536 | state.get_value(key) |
| 4537 | else: |
| 4538 | result = state.get_value(key) |
| 4539 | assert result == expected_result |
| 4540 | |
| 4541 | # Verify dirty state is not affected |
| 4542 | initial_dirty_vars = copy.copy(state.dirty_vars) |
| 4543 | state.get_value(key) |
| 4544 | assert state.dirty_vars == initial_dirty_vars |
| 4545 | |
| 4546 | |
| 4547 | def test_init_mixin() -> None: |
nothing calls this directly
no test coverage detected