KEMBAR78
chore: Fix two types of warnings in unit tests by chalmerlowe · Pull Request #2183 · googleapis/python-bigquery · GitHub
Skip to content

Conversation

@chalmerlowe
Copy link
Collaborator

@chalmerlowe chalmerlowe commented May 14, 2025

This commit reduces the number of times two warnings appear when running unit tests:

  1. PytestRemovedIn9Warning in tests/unit/test_opentelemetry_tracing.py: Removed a @pytest.mark.skipif decorator from a fixture. The skip condition is already present on the test methods that use the fixture.

Example warning:

/tmpfs/src/github/python-bigquery/tests/unit/test_opentelemetry_tracing.py:45:
  PytestRemovedIn9Warning: Marks applied to fixtures have no effect
  See docs: https://docs.pytest.org/en/stable/deprecations.html#applying-a-mark-to-a-fixture-function
  @pytest.mark.skipif(opentelemetry is None, reason="Require `opentelemetry`")
  1. FutureWarning in tests/unit/test_client.py: Updated calls to client.query() to include job_retry=None when job_id is also specified. This is to avoid ambiguity as BigQuery cannot retry a failed job with the exact same ID.

Example warning:

tests/unit/test_client.py::TestClient::test_query_preserving_explicit_default_job_config
  /tmpfs/src/github/python-bigquery/tests/unit/test_client.py:4951:
  FutureWarning: job_retry must be explicitly set to None if job_id is set.
  BigQuery cannot retry a failed job by using the exact
  same ID. Setting job_id without explicitly disabling
  job_retry will raise an error in the future. To avoid this
  warning, either use job_id_prefix instead (preferred) or
  set job_retry=None.
    client.query(query, job_id=job_id, location=self.LOCATION, job_config=None)

This commit addresses two warnings that appear when running unit tests:

1.  `PytestRemovedIn9Warning` in `tests/unit/test_opentelemetry_tracing.py`:
    Removed a `@pytest.mark.skipif` decorator from a fixture. The skip condition
    is already present on the test methods using the fixture.

2.  `FutureWarning` in `tests/unit/test_client.py`:
    Updated calls to `client.query()` to include `job_retry=None` when `job_id`
    is also specified. This is to avoid ambiguity as BigQuery cannot retry a
    failed job with the exact same ID.
@chalmerlowe chalmerlowe requested review from a team as code owners May 14, 2025 13:55
@chalmerlowe chalmerlowe requested a review from mrfaizal May 14, 2025 13:55
@product-auto-label product-auto-label bot added the size: s Pull request size is small. label May 14, 2025
@product-auto-label product-auto-label bot added the api: bigquery Issues related to the googleapis/python-bigquery API. label May 14, 2025
@chalmerlowe chalmerlowe removed the request for review from mrfaizal May 14, 2025 13:55
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels May 14, 2025
@chalmerlowe chalmerlowe merged commit 2140a51 into main May 14, 2025
18 checks passed
@chalmerlowe chalmerlowe deleted the fix-pytest-warnings branch May 14, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: bigquery Issues related to the googleapis/python-bigquery API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants