Skip to content

How to use fireducks when running pytest? #29

@MarcoGorelli

Description

@MarcoGorelli

If I have a test file with

import pytest
import narwhals as nw

@nw.narwhalify
def f(df):
    return df.with_columns(d=nw.col('d')*2)

@pytest.mark.parametrize("lib", ["pandas", "polars"])
def test_select_cols(lib):
    lib = pytest.importorskip(lib)

    df = nw.from_native(lib.DataFrame({"a": [1, 2], "b": [10, 20], "c": ["x", "y"]}))
    result = df.with_columns(d=nw.col('a')+1)
    assert result.columns == ['a', 'b', 'c', 'd']

then I can execute it with pytest test_me.py

How can I run pytest so that it uses fireducks instead of pandas? I tried

$ python -m fireducks.pandas pytest test_me.py
usage: fireducks.importhook [-h] [-m mod] [--delimiter CHAR] [--hook-import-module] [-q] [-v] [--suppress-logs] hook [hook ...] [--] prog [arg ...]
fireducks.importhook: error: invalid hooks: 'fireducks.pandas pytest'

but that fails

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions