Mark expected fail from within test function

Create issue
Issue #91 resolved
memedough created an issue


For expected failures can use decorator py.test.mark.xfail.

Suggest that for data driven tests it would be great to also be able to mark a test as expected fail imperatively within the test function.

This would be similar to skip which can be done with decorator or done within the test function.

I know I need this but do you think this is generally a good thing?


Comments (2)

  1. Holger Krekel repo owner
    • changed status to open

    I think an imperative xfail makes sense. Ronny on #pylib also come up with a need for this - he actually wants to call py.test.xfail during the setup phase.

  2. Holger Krekel repo owner

    fix issue91 introduce new py.test.xfail(reason) helper to imperatively mark a test as expected to fail. Can be used from within setup and test functions. This is useful especially for parametrized tests when certain configurations are expected-to-fail. In this case the declarative approach with the @py.test.mark.xfail cannot be used as it would mark all configurations as xfail.


  3. Log in to comment