3

My coworker Chris came up with this, and it works, but I wonder if there's a more "official" way to do this using unittest.TestCase in Python.

def tearDown(self):
    """ clean up by closing the browser window """
    if sys.exc_info() == (None, None, None):  # leave window open on fail
        self.driver.quit()
2

I don't know if this will work for pyunit but in Robot Framework, you can access singletons which represent the test suite and test case during the run. May be the unittest runner you are using provides the same functionality instead of having to inspect the stack.

  • Good point. I know nunit recently added a TestContext that allows you to determine whether the most recent test passed or failed. – Sam Woods Oct 24 '12 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.