def user_with_api_key(client: R2RClient):
    """Fixture that creates a user and returns their ID and API key details."""
    random_email = f"{uuid.uuid4()}@example.com"
    password = "api_key_test_password"
    user_id = client.users.create(random_email, password).results.id

    # Login to create an API key
    client.users.login(random_email, password)
    api_key_resp = client.users.create_api_key(user_id).results
    api_key = api_key_resp.api_key
    key_id = api_key_resp.key_id

    yield user_id, api_key, key_id

    # Cleanup
    try:
        client.users.delete_api_key(user_id, key_id)
    except:
        pass
    client.users.logout()
Fixture that creates a user and returns their ID and API key details.
py/tests/integration/test_users.py