I have this autouse fixture that will create a webdriver instance for each test:
@pytest.fixture(autouse=True)
def use_phantomjs(self):
self.wd = webdriver.PhantomJS()
yield
self.close_wd()
However, some of our tests cannot run on PhantomJS due to a bug with one of our APIs. These tests can only run on Chrome (or Firefox), so I created another method for a webdriver instance using Chrome:
def use_chrome(self):
self.wd = webdriver.Chrome()
which I plan to use on those tests, but I cannot get around the autouse fixture above.
Is there a way to somehow override the autouse fixture for some of our tests? I have tried using pytest.mark.usefixtures
for each test but it doesn't seem ideal having to put that decorator on each and every test. Someone mentioned using metaclasses but I haven't fully understood how they work yet, so I was wondering if there was some other way that I might have missed.