I have a session scoped fixture in conftest.py
@pytest.fixture(scope="session",autouse=True)
def log(request):
testlog = LogUtil(testconf.LOG_NAME).get()
return testlog
This is loaded and works as expected when a test method is defined in mytest.py as follows:
def test_hello_world(self, log):
log.info("hello world test")
Is there a way to use the fixture (since its autouse enabled) without having to add the extra "log" parameter to test methods?
def test_hello_world(self):
log.info("hello world test") #log is not found
@pytest.mark.usefixtures("log")
def test_hello_world2(self):
log.info("hello world test") #log is not found
def test_hello_world3(self,log):
log.info("hello world test") #log object is accessible here
Error - NameError: name 'log' is not defined