Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit a6c6558

Browse files
committed
update drop index test
1 parent a0a1d83 commit a6c6558

File tree

4 files changed

+36
-23
lines changed

4 files changed

+36
-23
lines changed

tests/unit/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import pytest
16+
17+
18+
@pytest.fixture(scope="session")
19+
def polars_session():
20+
pytest.importorskip("polars")
21+
22+
from bigframes.testing import polars_session
23+
24+
return polars_session.TestSession()

tests/unit/core/test_groupby.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@
2323
pytest.importorskip("pandas", minversion="2.0.0")
2424

2525

26-
# All tests in this file require polars to be installed to pass.
27-
@pytest.fixture(scope="module")
28-
def polars_session():
29-
from bigframes.testing import polars_session
30-
31-
return polars_session.TestSession()
32-
33-
3426
def test_groupby_df_iter_by_key_singular(polars_session):
3527
pd_df = pd.DataFrame({"colA": ["a", "a", "b", "c", "c"], "colB": [1, 2, 3, 4, 5]})
3628
bf_df = bpd.DataFrame(pd_df, session=polars_session)

tests/unit/test_dataframe.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
# limitations under the License.
1414

1515
import google.cloud.bigquery
16+
import pandas as pd
1617
import pytest
1718

1819
import bigframes.dataframe
20+
import bigframes.session
1921
from bigframes.testing import mocks
2022

2123

@@ -138,14 +140,17 @@ def test_dataframe_drop_columns_inplace_returns_none(monkeypatch: pytest.MonkeyP
138140
assert dataframe.columns.to_list() == ["col2"]
139141

140142

141-
def test_dataframe_drop_index_inplace_returns_none(monkeypatch: pytest.MonkeyPatch):
142-
dataframe = mocks.create_dataframe(
143-
monkeypatch, data={"col1": [1, 2, 3], "index_col": [0, 1, 2]}
144-
).set_index("index_col")
145-
# TODO(swast): Support dataframe.index.to_list()
146-
# assert dataframe.index.to_list() == [0, 1, 2]
143+
def test_dataframe_drop_index_inplace_returns_none(
144+
# Drop index depends on the actual data, not just metadata, so use the
145+
# local engine for more robust testing.
146+
polars_session: bigframes.session.Session,
147+
):
148+
dataframe = polars_session.read_pandas(
149+
pd.DataFrame({"col1": [1, 2, 3], "index_col": [0, 1, 2]}).set_index("index_col")
150+
)
151+
assert dataframe.index.to_list() == [0, 1, 2]
147152
assert dataframe.drop(index=[0, 2], inplace=True) is None
148-
# assert dataframe.index.to_list() == [1]
153+
assert dataframe.index.to_list() == [1]
149154

150155

151156
def test_dataframe_drop_columns_returns_new_dataframe(monkeypatch: pytest.MonkeyPatch):

tests/unit/test_local_engine.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
pytest.importorskip("pandas", minversion="2.0.0")
2525

2626

27-
# All tests in this file require polars to be installed to pass.
28-
@pytest.fixture(scope="module")
29-
def polars_session():
30-
from bigframes.testing import polars_session
31-
32-
return polars_session.TestSession()
33-
34-
3527
@pytest.fixture(scope="module")
3628
def small_inline_frame() -> pd.DataFrame:
3729
df = pd.DataFrame(

0 commit comments

Comments
 (0)