Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit eec3b40

Browse files
Fix two types of warnings in unit tests
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.
1 parent 0217637 commit eec3b40

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

tests/unit/test_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4719,7 +4719,7 @@ def test_query_w_api_method_query_and_job_id_fails(self):
47194719
client._connection = make_connection({})
47204720

47214721
with self.assertRaises(TypeError) as exc:
4722-
client.query(query, job_id="abcd", api_method="QUERY")
4722+
client.query(query, job_id="abcd", api_method="QUERY", job_retry=None)
47234723
self.assertIn(
47244724
"`job_id` was provided, but the 'QUERY' `api_method` was requested",
47254725
exc.exception.args[0],
@@ -4774,7 +4774,7 @@ def test_query_w_explicit_project(self):
47744774
conn = client._connection = make_connection(resource)
47754775

47764776
client.query(
4777-
query, job_id=job_id, project="other-project", location=self.LOCATION
4777+
query, job_id=job_id, project="other-project", location=self.LOCATION, job_retry=None
47784778
)
47794779

47804780
# Check that query actually starts the job.
@@ -4833,7 +4833,7 @@ def test_query_w_explicit_job_config(self):
48334833
original_config_copy = copy.deepcopy(job_config)
48344834

48354835
client.query(
4836-
query, job_id=job_id, location=self.LOCATION, job_config=job_config
4836+
query, job_id=job_id, location=self.LOCATION, job_config=job_config, job_retry=None
48374837
)
48384838

48394839
# Check that query actually starts the job.
@@ -5178,7 +5178,7 @@ def test_query_w_udf_resources(self):
51785178
config.udf_resources = udf_resources
51795179
config.use_legacy_sql = True
51805180

5181-
job = client.query(QUERY, job_config=config, job_id=JOB)
5181+
job = client.query(QUERY, job_config=config, job_id=JOB, job_retry=None)
51825182

51835183
self.assertIsInstance(job, QueryJob)
51845184
self.assertIs(job._client, client)
@@ -5234,7 +5234,7 @@ def test_query_w_query_parameters(self):
52345234
config = QueryJobConfig()
52355235
config.query_parameters = query_parameters
52365236

5237-
job = client.query(QUERY, job_config=config, job_id=JOB)
5237+
job = client.query(QUERY, job_config=config, job_id=JOB, job_retry=None)
52385238

52395239
self.assertIsInstance(job, QueryJob)
52405240
self.assertIs(job._client, client)
@@ -5277,7 +5277,7 @@ def test_query_job_rpc_fail_w_random_error(self):
52775277
)
52785278
with job_begin_patcher:
52795279
with pytest.raises(Unknown, match="Not sure what went wrong."):
5280-
client.query("SELECT 1;", job_id="123")
5280+
client.query("SELECT 1;", job_id="123", job_retry=None)
52815281

52825282
def test_query_job_rpc_fail_w_conflict_job_id_given(self):
52835283
from google.api_core.exceptions import Conflict
@@ -5293,7 +5293,7 @@ def test_query_job_rpc_fail_w_conflict_job_id_given(self):
52935293
)
52945294
with job_begin_patcher:
52955295
with pytest.raises(Conflict, match="Job already exists."):
5296-
client.query("SELECT 1;", job_id="123")
5296+
client.query("SELECT 1;", job_id="123", job_retry=None)
52975297

52985298
def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_fails(self):
52995299
from google.api_core.exceptions import Conflict

tests/unit/test_opentelemetry_tracing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
TEST_SPAN_ATTRIBUTES = {"foo": "baz"}
4343

4444

45-
@pytest.mark.skipif(opentelemetry is None, reason="Require `opentelemetry`")
4645
@pytest.fixture
4746
def setup():
4847
importlib.reload(opentelemetry_tracing)

0 commit comments

Comments
 (0)