Skip to content

REF/TST: mixed use of mock/monkeypatch #24557

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 5, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions pandas/tests/io/test_gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@
from pandas import DataFrame, compat
import pandas.util.testing as tm

try:
from unittest import mock
except ImportError:
mock = pytest.importorskip("mock")


api_exceptions = pytest.importorskip("google.api_core.exceptions")
bigquery = pytest.importorskip("google.cloud.bigquery")
service_account = pytest.importorskip("google.oauth2.service_account")
Expand Down Expand Up @@ -104,8 +98,10 @@ def make_mixed_dataframe_v2(test_size):
def test_read_gbq_without_dialect_warns_future_change(monkeypatch):
# Default dialect is changing to standard SQL. See:
# https://github.com/pydata/pandas-gbq/issues/195
mock_read_gbq = mock.Mock()
mock_read_gbq.return_value = DataFrame([[1.0]])

def mock_read_gbq(*args, **kwargs):
return DataFrame([[1.0]])

monkeypatch.setattr(pandas_gbq, 'read_gbq', mock_read_gbq)
with tm.assert_produces_warning(FutureWarning):
pd.read_gbq("SELECT 1")
Expand Down