Skip to content

Commit

Permalink
Fix test assertions to not assert list but check contents (#2202)
Browse files Browse the repository at this point in the history
Using `assert <list> ` will pass any non-empty list, i.e.:

```python
assert [False]
# because:
bool([False])
True
```
  • Loading branch information
zundertj committed Dec 28, 2021
1 parent a982b50 commit df973a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions py-polars/tests/test_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ def test_from_pandas_nan_to_none() -> None:
out_true: pl.DataFrame = pl.from_pandas(df) # type: ignore
out_false: pl.DataFrame = pl.from_pandas(df, nan_to_none=False) # type: ignore
df.loc[2, "nulls"] = pd.NA
assert [val is None for val in out_true["nulls"]]
assert [np.isnan(val) for val in out_false["nulls"][1:]]
assert all(val is None for val in out_true["nulls"])
assert all(np.isnan(val) for val in out_false["nulls"][1:])
with pytest.raises(ArrowInvalid, match="Could not convert"):
pl.from_pandas(df, nan_to_none=False)

Expand Down

0 comments on commit df973a9

Please sign in to comment.