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

Commit 9bf17c4

Browse files
committed
test: check in some testcase
1 parent 3ffb82a commit 9bf17c4

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from bigframes.testing import mocks
2+
3+
4+
def test_clear_api_methods_log():
5+
"""
6+
This test exists to provoke a race condition in other tests.
7+
It makes a simple query which has the side effect of clearing
8+
the global _api_methods list in the log_adapter.
9+
"""
10+
session = mocks.create_bigquery_session()
11+
_ = session.bqclient.query("SELECT 1")

tests/unit/session/test_read_gbq_colab.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,21 @@
2222
import pandas
2323
import pytest
2424

25+
import bigframes.core.log_adapter
2526
from bigframes.testing import mocks
2627

2728

2829
def test_read_gbq_colab_includes_label():
2930
"""Make sure we can tell direct colab usage apart from regular read_gbq usage."""
3031
session = mocks.create_bigquery_session()
31-
_ = session._read_gbq_colab("SELECT 'read-gbq-colab-test'")
32+
33+
# The mock session does not fully simulate the logging of API methods, so
34+
# we patch the global list of API methods to ensure the label is set.
35+
with mock.patch.object(
36+
bigframes.core.log_adapter, "_api_methods", ["session-read_gbq_colab"]
37+
):
38+
_ = session._read_gbq_colab("SELECT 'read-gbq-colab-test'")
39+
3240
configs = session._job_configs # type: ignore
3341

3442
label_values = []

0 commit comments

Comments
 (0)