| 
31 | 31 | 
 
  | 
32 | 32 | import narwhals as nw  | 
33 | 33 | import narwhals.stable.v1 as nw_v1  | 
34 |  | -from tests.utils import maybe_get_modin_df  | 
 | 34 | +from tests.utils import Constructor, maybe_get_modin_df  | 
35 | 35 | 
 
  | 
36 | 36 | if TYPE_CHECKING:  | 
37 | 37 |     from _pytest.mark import ParameterSet  | 
@@ -286,7 +286,13 @@ def test_series_only_sqlframe() -> None:  # pragma: no cover  | 
286 | 286 |     ("eager_only", "context"),  | 
287 | 287 |     [  | 
288 | 288 |         (False, does_not_raise()),  | 
289 |  | -        (True, pytest.raises(TypeError, match="Cannot only use `eager_only`")),  | 
 | 289 | +        (  | 
 | 290 | +            True,  | 
 | 291 | +            pytest.raises(  | 
 | 292 | +                TypeError,  | 
 | 293 | +                match="Cannot only use `series_only`, `eager_only` or `eager_or_interchange_only` with sqlframe DataFrame",  | 
 | 294 | +            ),  | 
 | 295 | +        ),  | 
290 | 296 |     ],  | 
291 | 297 | )  | 
292 | 298 | @pytest.mark.skipif(sys.version_info < (3, 9), reason="too old for sqlframe")  | 
@@ -548,3 +554,28 @@ def test_pyspark_connect_deps_2517() -> None:  # pragma: no cover  | 
548 | 554 |     spark = SparkSession.builder.getOrCreate()  | 
549 | 555 |     # Check this doesn't raise  | 
550 | 556 |     nw.from_native(spark.createDataFrame([(1,)], ["a"]))  | 
 | 557 | + | 
 | 558 | + | 
 | 559 | +@pytest.mark.parametrize(  | 
 | 560 | +    ("eager_only", "pass_through", "context"),  | 
 | 561 | +    [  | 
 | 562 | +        (False, False, does_not_raise()),  | 
 | 563 | +        (False, True, does_not_raise()),  | 
 | 564 | +        (True, True, does_not_raise()),  | 
 | 565 | +        (True, False, pytest.raises(TypeError, match="Cannot only use")),  | 
 | 566 | +    ],  | 
 | 567 | +)  | 
 | 568 | +def test_eager_only_pass_through_main(  | 
 | 569 | +    constructor: Constructor, *, eager_only: bool, pass_through: bool, context: Any  | 
 | 570 | +) -> None:  | 
 | 571 | +    if not any(s in str(constructor) for s in ("pyspark", "dask", "ibis", "duckdb")):  | 
 | 572 | +        pytest.skip(reason="Non lazy or polars")  | 
 | 573 | + | 
 | 574 | +    df = constructor(data)  | 
 | 575 | + | 
 | 576 | +    with context:  | 
 | 577 | +        res = nw.from_native(df, eager_only=eager_only, pass_through=pass_through)  # type: ignore[call-overload]  | 
 | 578 | +        if eager_only and pass_through:  | 
 | 579 | +            assert not isinstance(res, nw.LazyFrame)  | 
 | 580 | +        else:  | 
 | 581 | +            assert isinstance(res, nw.LazyFrame)  | 
0 commit comments