This repository was archived by the owner on May 7, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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" )
Original file line number Diff line number Diff line change 2222import pandas
2323import pytest
2424
25+ import bigframes .core .log_adapter
2526from bigframes .testing import mocks
2627
2728
2829def 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 = []
You can’t perform that action at this time.
0 commit comments