Skip to content

Commit

Permalink
adds controls to skip testing if pandas exceeds 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
chalmerlowe committed Aug 18, 2023
1 parent 9bb8f14 commit ddd86bd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion tests/unit/job/test_query_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import json

import mock
import pkg_resources
import pytest


Expand Down Expand Up @@ -48,6 +49,11 @@
from .helpers import _make_client
from .helpers import _make_job_resource

if pandas is not None:
PANDAS_INSTALLED_VERSION = pkg_resources.get_distribution("pandas").parsed_version
else:
PANDAS_INSTALLED_VERSION = pkg_resources.parse_version("0.0.0")

pandas = pytest.importorskip("pandas")

try:
Expand Down Expand Up @@ -645,7 +651,9 @@ def test_to_dataframe_bqstorage_no_pyarrow_compression():
max_stream_count=0,
)


@pytest.mark.skipif(
PANDAS_INSTALLED_VERSION >= pkg_resources.parse_version("2.0.0"), reason=""
)
@pytest.mark.skipif(pyarrow is None, reason="Requires `pyarrow`")
def test_to_dataframe_column_dtypes():
from google.cloud.bigquery.job import QueryJob as target_class
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3682,6 +3682,9 @@ def test_to_dataframe_w_dtypes_mapper(self):
self.assertEqual(df.timestamp.dtype.name, "object")

@unittest.skipIf(pandas is None, "Requires `pandas`")
@pytest.mark.skipif(
PANDAS_INSTALLED_VERSION >= pkg_resources.parse_version("2.0.0"), reason=""
)
def test_to_dataframe_w_none_dtypes_mapper(self):
from google.cloud.bigquery.schema import SchemaField

Expand Down
11 changes: 10 additions & 1 deletion tests/unit/test_table_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import datetime
import decimal
from unittest import mock
import pkg_resources

import pytest

Expand All @@ -26,14 +27,22 @@

TEST_PATH = "/v1/project/test-proj/dataset/test-dset/table/test-tbl/data"

if pandas is not None:
PANDAS_INSTALLED_VERSION = pkg_resources.get_distribution("pandas").parsed_version
else:
PANDAS_INSTALLED_VERSION = pkg_resources.parse_version("0.0.0")



@pytest.fixture
def class_under_test():
from google.cloud.bigquery.table import RowIterator

return RowIterator


@pytest.mark.skipif(
PANDAS_INSTALLED_VERSION >= pkg_resources.parse_version("2.0.0"), reason=""
)
def test_to_dataframe_nullable_scalars(monkeypatch, class_under_test):
# See tests/system/test_arrow.py for the actual types we get from the API.
arrow_schema = pyarrow.schema(
Expand Down

0 comments on commit ddd86bd

Please sign in to comment.