Skip to content

Choking on parametrized tests with pandas.DataFrame #57

@pcorpet

Description

@pcorpet

With v3, when I'm using a pandas.DataFrame in the parameters of one of my test function I end up with an error:
`ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()``

I'm not sure why it was revealed by v3, but I will send a fix as I believe get_parametrized_fixtures only need to collect parameters if they are strings.

Full repro file:

import pandas as pd
import pytest

@pytest.mark.parametrize(
  "input_df,expected",
  [(pd.DataFrame([{"a": 1}, {"a": 2}]), 3), (pd.DataFrame([{"a": 5}, {"a": 2}]), 7)]
)
def test_me(input_df: pd.DataFrame, expected: int) -> None:
  ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions