Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Oct 25, 2024
1 parent 9ac59d2 commit 23e35fa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pandas.testing import assert_series_equal

import narwhals.stable.v1 as nw
from narwhals._pandas_like.utils import reset_index_no_copy
from tests.utils import PANDAS_VERSION
from tests.utils import get_module_version_as_tuple

Expand Down Expand Up @@ -147,3 +148,14 @@ def test_maybe_convert_dtypes_polars() -> None:
def test_get_trivial_version_with_uninstalled_module() -> None:
result = get_module_version_as_tuple("non_existent_module")
assert result == (0, 0, 0)


def test_reset_index_no_copy() -> None:
df = pd.DataFrame({"a": [1, 2, 3], "b": [4.0, 5.0, 6.0]}).set_index("a")
reset_index_no_copy(df, pd)
pd.testing.assert_frame_equal(
df, pd.DataFrame({"b": [4.0, 5.0, 6.0], "a": [1, 2, 3]})
)
df.index.name = "b"
with pytest.raises(ValueError, match="Cannot insert column"):
reset_index_no_copy(df, pd)

0 comments on commit 23e35fa

Please sign in to comment.