Skip to content

Commit

Permalink
remove stable api docstring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Jan 11, 2025
1 parent a8e5003 commit 1d404f6
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions tests/stable_api_test.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from __future__ import annotations

from datetime import datetime
from datetime import timedelta
from typing import Any

import polars as pl
import pytest

import narwhals as nw
Expand Down Expand Up @@ -91,72 +88,3 @@ def test_stable_api_completeness() -> None:
assert not extra
missing = set(main_namespace_api).difference(v_1_api).difference({"stable"})
assert not missing


def test_stable_api_docstrings() -> None:
main_namespace_api = nw.__all__
for item in main_namespace_api:
if getattr(nw, item).__doc__ is None:
continue
v1_doc = getattr(nw_v1, item).__doc__
nw_doc = getattr(nw, item).__doc__
assert v1_doc == nw_doc, item


def test_dataframe_docstrings() -> None:
stable_df = nw_v1.from_native(pl.DataFrame())
df = nw.from_native(pl.DataFrame())
api = [i for i in df.__dir__() if not i.startswith("_")]
for item in api:
assert (
getattr(stable_df, item).__doc__.replace(
"import narwhals.stable.v1 as nw", "import narwhals as nw"
)
== getattr(df, item).__doc__
), item


def test_lazyframe_docstrings() -> None:
stable_df = nw_v1.from_native(pl.LazyFrame())
df = nw.from_native(pl.LazyFrame())
api = [i for i in df.__dir__() if not i.startswith("_")]
for item in api:
if item in ("schema", "columns"):
# to avoid performance warning
continue
assert (
getattr(stable_df, item).__doc__.replace(
"import narwhals.stable.v1 as nw", "import narwhals as nw"
)
== getattr(df, item).__doc__
)


def test_series_docstrings() -> None:
stable_df = nw_v1.from_native(pl.Series(), series_only=True)
df = nw.from_native(pl.Series(), series_only=True)
api = [i for i in df.__dir__() if not i.startswith("_")]
for item in api:
if getattr(df, item).__doc__ is None:
continue
assert (
getattr(stable_df, item).__doc__.replace(
"import narwhals.stable.v1 as nw", "import narwhals as nw"
)
== getattr(df, item).__doc__
), item


def test_dtypes(request: pytest.FixtureRequest, constructor: Constructor) -> None:
if "pyspark" in str(constructor):
request.applymarker(pytest.mark.xfail)

df = nw_v1.from_native(
constructor({"a": [1], "b": [datetime(2020, 1, 1)], "c": [timedelta(1)]})
)
dtype = df.collect_schema()["b"]
assert dtype in {nw_v1.Datetime}
assert isinstance(dtype, nw_v1.Datetime)
dtype = df.collect_schema()["c"]
assert dtype in {nw_v1.Duration}
assert isinstance(dtype, nw_v1.Duration)

0 comments on commit 1d404f6

Please sign in to comment.