Does fixture teardown run when the test fails?
QuizEasy-MediumPython onlyAsked in: Cisco
@pytest.fixture
def driver():
d = webdriver.Chrome()
yield d
d.quit()A test that uses this fixture fails with an assertion error. Does d.quit() run?
- Yes: the code after yield runs after the test, whatever its result
- No: teardown runs only for passing tests
- Only if the test is marked with usefixtures
- Only with the -s option
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.