Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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()
share|improve this question
add comment

1 Answer

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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