Skip to content

Commit ae2a070

Browse files
committed
TST: Use pandas.api.types functions for dtypes checks
This should make checking for expected dtypes more robust.
1 parent b2e0bcb commit ae2a070

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tests/system/test_gbq.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import google.oauth2.service_account
88
import numpy as np
99
import pandas
10+
import pandas.api.types
1011
import pandas.util.testing as tm
1112
from pandas import DataFrame, NaT, compat
1213
from pandas.compat import range, u
@@ -364,16 +365,16 @@ def test_should_properly_handle_arbitrary_datetime(self, project_id):
364365
)
365366

366367
@pytest.mark.parametrize(
367-
"expression, type_",
368+
"expression, is_expected_dtype",
368369
[
369-
("current_date()", "<M8[ns]"),
370-
("current_timestamp()", "datetime64[ns]"),
371-
("current_datetime()", "<M8[ns]"),
372-
("TRUE", bool),
373-
("FALSE", bool),
370+
("current_date()", pandas.api.types.is_datetime64_ns_dtype),
371+
("current_timestamp()", pandas.api.types.is_datetime64_ns_dtype),
372+
("current_datetime()", pandas.api.types.is_datetime64_ns_dtype),
373+
("TRUE", pandas.api.types.is_bool_dtype),
374+
("FALSE", pandas.api.types.is_bool_dtype),
374375
],
375376
)
376-
def test_return_correct_types(self, project_id, expression, type_):
377+
def test_return_correct_types(self, project_id, expression, is_expected_dtype):
377378
"""
378379
All type checks can be added to this function using additional
379380
parameters, rather than creating additional functions.
@@ -389,7 +390,7 @@ def test_return_correct_types(self, project_id, expression, type_):
389390
credentials=self.credentials,
390391
dialect="standard",
391392
)
392-
assert df["_"].dtype == type_
393+
assert is_expected_dtype(df["_"].dtype)
393394

394395
def test_should_properly_handle_null_timestamp(self, project_id):
395396
query = "SELECT TIMESTAMP(NULL) AS null_timestamp"

0 commit comments

Comments
 (0)