Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:09:17+00:00 2026-06-11T19:09:17+00:00

I’m creating the test cases for web-tests using Jenkins, Python, Selenium2(webdriver) and Py.test frameworks.

  • 0

I’m creating the test cases for web-tests using Jenkins, Python, Selenium2(webdriver) and Py.test frameworks.

So far I’m organizing my tests in the following structure:

each Class is the Test Case and each test_ method is a Test Step.

This setup works GREAT when everything is working fine, however when one step crashes the rest of the “Test Steps” go crazy. I’m able to contain the failure inside the Class (Test Case) with the help of teardown_class(), however I’m looking into how to improve this.

What I need is somehow skip(or xfail) the rest of the test_ methods within one class if one of them has failed, so that the rest of the test cases are not run and marked as FAILED (since that would be false positive)

Thanks!

UPDATE: I’m not looking or the answer “it’s bad practice” since calling it that way is very arguable. (each Test Class is independent – and that should be enough).

UPDATE 2: Putting “if” condition in each test method is not an option – is a LOT of repeated work. What I’m looking for is (maybe) somebody knows how to use the hooks to the class methods.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:09:18+00:00Added an answer on June 11, 2026 at 7:09 pm

    I like the general “test-step” idea. I’d term it as “incremental” testing and it makes most sense in functional testing scenarios IMHO.

    Here is a an implementation that doesn’t depend on internal details of pytest (except for the official hook extensions). Copy this into your conftest.py:

    import pytest
    
    def pytest_runtest_makereport(item, call):
        if "incremental" in item.keywords:
            if call.excinfo is not None:
                parent = item.parent
                parent._previousfailed = item
    
    def pytest_runtest_setup(item):
        previousfailed = getattr(item.parent, "_previousfailed", None)
        if previousfailed is not None:
            pytest.xfail("previous test failed (%s)" % previousfailed.name)
    

    If you now have a “test_step.py” like this:

    import pytest
    
    @pytest.mark.incremental
    class TestUserHandling:
        def test_login(self):
            pass
        def test_modification(self):
            assert 0
        def test_deletion(self):
            pass
    

    then running it looks like this (using -rx to report on xfail reasons):

    (1)hpk@t2:~/p/pytest/doc/en/example/teststep$ py.test -rx
    ============================= test session starts ==============================
    platform linux2 -- Python 2.7.3 -- pytest-2.3.0.dev17
    plugins: xdist, bugzilla, cache, oejskit, cli, pep8, cov, timeout
    collected 3 items
    
    test_step.py .Fx
    
    =================================== FAILURES ===================================
    ______________________ TestUserHandling.test_modification ______________________
    
    self = <test_step.TestUserHandling instance at 0x1e0d9e0>
    
        def test_modification(self):
    >       assert 0
    E       assert 0
    
    test_step.py:8: AssertionError
    =========================== short test summary info ============================
    XFAIL test_step.py::TestUserHandling::()::test_deletion
      reason: previous test failed (test_modification)
    ================ 1 failed, 1 passed, 1 xfailed in 0.02 seconds =================
    

    I am using “xfail” here because skips are rather for wrong environments or missing dependencies, wrong interpreter versions.

    Edit: Note that neither your example nor my example would directly work with distributed testing. For this, the pytest-xdist plugin needs to grow a way to define groups/classes to be sent whole-sale to one testing slave instead of the current mode which usually sends test functions of a class to different slaves.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have thousands of HTML files to process using Groovy/Java and I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.