[pytest-dev] parametrize + xfail

Brianna Laugher brianna.laugher at gmail.com
Mon Apr 22 08:05:48 CEST 2013

Hi again :)

A common problem I have is that I have a test that is parametrized with
py.test.mark.parametrize, I discover a bug, I want to add another test case
for that bug and mark it as xfail.

I have done something based on
for pytest_generate type functions, but it is awkward to do without
disrupting the existing cases, and somewhat overkill in cases where the
xfail is likely to be resolved (the bug is fixed) soon.

With py.test.mark.parametrize, I notice

I was just thinking about this now and I wonder if it is possible to build
a decorator like this?

@py.test.mark.parametrizexfail('duration', 'expectedBrackets'), [
    (7, [None, None, None, 7]),
    (19, [None, 7, 6, 6]),
@py.test.mark.parametrize(('duration', 'expectedBrackets'), [
    (24, [6, 6, 6, 6]),
    (23, [6, 6, 6, 6]),
    (25, [6, 6, 6, 6]),

So 5 cases would be fed into the test, with only the first two marked as

Also while I'm at it, it could be good for pytest to issue a warning if
someone uses a mark called parameterize, parametrise or parameterise,
because I've been caught pondering why a mark wasn't working properly at
least once :)


They've just been waiting in a mountain for the right moment:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pytest-dev/attachments/20130422/5616c387/attachment.html>

More information about the Pytest-dev mailing list