Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix(tests): Use `as_series=False` in `assert_frame_equal` to compare Narwhals dataframes (#6035)

Francesco Bruzzesicacdbb965208
diff --git a/tests/_plugins/ui/_impl/tables/test_narwhals.py b/tests/_plugins/ui/_impl/tables/test_narwhals.py
index b439e5f0b3..2e82047d05 100644
--- a/tests/_plugins/ui/_impl/tables/test_narwhals.py
+++ b/tests/_plugins/ui/_impl/tables/test_narwhals.py
@@ -5,7 +5,7 @@ import json
import time
import unittest
from math import isnan
-from typing import Any
+from typing import TYPE_CHECKING, Any
import narwhals.stable.v1 as nw
import pytest
@@ -31,6 +31,9 @@ from tests._data.mocks import (
)
from tests.mocks import snapshotter
+if TYPE_CHECKING:
+ from narwhals.stable.v1.typing import DataFrameT
+
HAS_DEPS = DependencyManager.polars.has()
snapshot = snapshotter(__file__)
@@ -45,8 +48,8 @@ SUPPORTED_LIBS: list[DFType] = [
]
-def assert_frame_equal(a: Any, b: Any) -> None:
- return a.to_dict() == b.to_dict()
+def assert_frame_equal(a: DataFrameT, b: DataFrameT) -> None:
+ return a.to_dict(as_series=False) == b.to_dict(as_series=False)
@pytest.mark.skipif(not HAS_DEPS, reason="optional dependencies not installed")