Support xfail inside parameterized.expand
What's the proper way to indicate that a test will fail (e.g., pytest's "xfail") with parameterized.expand?
I've tried using pytest.mark with parameterized.expand:
import unittest
import pytest
from parameterized import parameterized
class ModelRegressionTestCase(unittest.TestCase):
def setUp(self):
self.model = load_model()
@parameterized.expand(
[
("Word", "Word"),
pytest.param("Word Second", "Word second",
marks=pytest.mark.xfail(reason="The reason it fails")),
]
)
def test_sanity(self, x, y):
expectation = {"answer": y, "score": 1}
result = self.model.predict(x)
self.assertEqual(expectation, result)
But perhaps those are incompatible. I get a TypeError:
=================================== FAILURES ===================================
____________________ ModelRegressionTestCase.test_sanity_2 _____________________
a = (<test.test_model.ModelRegressionTestCase testMethod=test_sanity_2>,)
@wraps(func)
def standalone_func(*a):
> return func(*(a + p.args), **p.kwargs)
E TypeError: test_sanity() takes 3 positional arguments but 4 were given
../.local/lib/python3.6/site-packages/parameterized/parameterized.py:533: TypeError
Does parameterized support something like xfail specifically in the context of the expand decorator?
I think there's currently no way to expect an exception as beautifully as pytest.mark.xfail would allow to do.
Also, you are using pytest.param in your example, but parameterized has its own param class - it doesn't use pytest's one.
I would be very happy to see a xfail implementation in parameterized :-)
Bumping this! xfail in parameterized would be a very helpful addition!