Skip to content
Snippets Groups Projects
Commit ec6d77d8 authored by Bert Palm's avatar Bert Palm 🎇
Browse files

FIX: use `with pytest.raises` instead of `pytest.xfail`

parent 8ab6b492
No related branches found
No related tags found
1 merge request!462More tests
Pipeline #93444 passed with stage
in 2 minutes and 3 seconds
......@@ -313,20 +313,7 @@ def test_to_frame(data: Union[pd.DataFrame, dios.DictOfSeries, Dict[str, pd.Seri
@pytest.mark.parametrize(
"columns",
[
# ok
["x", "y"],
pd.Index(["x", "y"]),
# expect to fail
pytest.param(
pd.Index(["x", "x"]), marks=pytest.mark.xfail(reason="not unique")
),
pytest.param(pd.Index(["x"]), marks=pytest.mark.xfail(reason="wrong length")),
pytest.param(
pd.Index(["x", "x", "x"]),
marks=pytest.mark.xfail(reason="wrong length"),
),
],
[["x", "y"], pd.Index(["x", "y"])],
)
def test_columns_setter(columns):
flags = Flags(
......@@ -335,3 +322,21 @@ def test_columns_setter(columns):
flags.columns = columns
for c in columns:
assert c in flags.columns
@pytest.mark.parametrize(
"columns,err",
[
("foooo", TypeError), # cannot cast to Index
(pd.Index(["x", "x"]), TypeError), # duplicates
(pd.Index([1, 2]), TypeError), # not string
(pd.Index(["x", "y", "z"]), ValueError), # wrong length
(pd.Index(["x"]), ValueError), # wrong length
],
)
def test_columns_setter_raises(columns, err):
flags = Flags(
{"a": pd.Series([1, 2], dtype=float), "b": pd.Series([1, 2], dtype=float)}
)
with pytest.raises(err):
flags.columns = columns
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment