Skip to content

google-auth: Tests in test__default.py fail if GOOGLE_CLOUD_PROJECT is set in the local environment #17759

Open

Description

@nbayati

If you run the test suite locally with GOOGLE_CLOUD_PROJECT set in your environment, several tests in tests/test__default.py (such as test_default_early_out and test_default_gdch_service_account_credentials) will fail.

The google.auth.default() function reads os.environ.get("GOOGLE_CLOUD_PROJECT") to determine the project ID. Because os.environ isn't fully mocked or cleared in these tests, the local environment variable takes precedence over the mocked project_id sentinels, resulting in assertion failures.

To fix this, we should properly isolate the tests from the local environment by clearing or mocking the project-related environment variables (e.g., using pytest's monkeypatch.delenv) inside test__default.py.

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    priority: p3Desirable enhancement or fix. May not be included in next release.
    on Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autheffort: lowpriority: p3Desirable enhancement or fix. May not be included in next release.testingtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions