Skip to content

Test coverage gap for google.auth.api_key ImportError #334

@chalmerlowe

Description

@chalmerlowe

File: google/cloud/client/__init__.py
Link: https://github.com/googleapis/python-cloud-core/blob/main/google/cloud/client/__init__.py#L33-L38

Description:
The current test suite does not cover both branches in the try/except for importing google.auth.api_key. This means the scenario where google.auth.api_key is not available is not tested and coverage testing fails.

  try:
      import google.auth.api_key
      HAS_GOOGLE_AUTH_API_KEY = True
  except ImportError:
      HAS_GOOGLE_AUTH_API_KEY = False

Desired Action:
Investigate whether it's feasible and necessary to add a test case that simulates google.auth.api_key not being importable. If this is a valid state, a test should be added to ensure HAS_GOOGLE_AUTH_API_KEY is correctly set to False. If it's not a practically reachable state in supported environments, document why.

Temporary Measure:
The lines are currently marked with # pragma: no cover to unblock other work, but this should be revisited.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions