diff --git a/bigquery/tests/unit/test_magics.py b/bigquery/tests/unit/test_magics.py index 6e8c941bbc028..7cb153230f4d8 100644 --- a/bigquery/tests/unit/test_magics.py +++ b/bigquery/tests/unit/test_magics.py @@ -559,9 +559,17 @@ def test_bigquery_magic_w_maximum_bytes_billed_invalid(): ip.extension_manager.load_extension("google.cloud.bigquery") magics.context._project = None + credentials_mock = mock.create_autospec( + google.auth.credentials.Credentials, instance=True + ) + default_patch = mock.patch( + "google.auth.default", return_value=(credentials_mock, "general-project") + ) + client_query_patch = mock.patch("google.cloud.bigquery.client.Client.query") + sql = "SELECT 17 AS num" - with pytest.raises(ValueError): + with pytest.raises(ValueError), default_patch, client_query_patch: ip.run_cell_magic("bigquery", "--maximum_bytes_billed=abc", sql)