У меня есть приспособление с привязкой к сеансу в conftest.py
@pytest.fixture(scope="session",autouse=True)
def log(request):
testlog = LogUtil(testconf.LOG_NAME).get()
return testlog
Он загружается и работает должным образом, если метод тестирования определен в mytest.py следующим образом:
def test_hello_world(self, log):
log.info("hello world test")
Есть ли способ использовать прибор (поскольку его автозапуск включен) без необходимости добавлять дополнительный параметр «log» в методы тестирования?
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
Ошибка - NameError: имя журнала не определено