pytest AttributeError when using fixture with yield
问题 I am using pytest fixture with yield. But receive AttributeError when trying to get value that yield returns conftest.py @pytest.fixture() def driver_setup(): driver = webdriver.Firefox() yield driver driver.quit() basetest.py @pytest.mark.usefixtures("driver_setup") class BaseTest: pass test_example.py class TestExample(BaseTest): def test_example(self): self.driver.get(url) pass Output: AttributeError: 'TestExample' object has no attribute 'driver' 回答1: You need to update driver_setup