async def test_initialize_with_state(test_state: type[ATestState], token: str):
    """Test setting the state of an app.

    Args:
        test_state: The default state.
        token: a Token.
    """
    app = App(_state=test_state)
    assert app._state == test_state

    # Get a state for a given token.
    state = await app.state_manager.get_state(_substate_key(token, test_state))
    assert isinstance(state, test_state)
    assert state.var == 0

    if isinstance(app.state_manager, StateManagerRedis):
        await app.state_manager.close()
Test setting the state of an app.

    Args:
        test_state: The default state.
        token: a Token.
    
tests/units/test_app.py