You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to get log file for each worker. I have followed #331. I have added code in conftest.py and pytest.ini file, but still separate log files are not generated. Below are the details of my files. @nbartos@nicoddemus@marcosanchotene Could someone please help me out.
Also how the value of PYTEST_XDIST_WORKER' is picked up do we need to define it somewhere. I am invoking my tests from commandline through this pytest -v -s -m "smoke or regression" -n 3 --worker-log-file Logs/pytest-%w.log TestCases/
import os
from selenium import webdriver
import logging
import pytest
from Utilities.readProperties import ReadConfig
from dotenv import load_dotenv
# Load environment variables from the .env file
load_dotenv()
def pytest_addoption(parser): # This will get the value from Commandline
parser.addoption("--browser")
parser.addoption("--mode")
log_help_text = 'Similar to log_file, but %%w will be replaced with a worker identifier.'
parser.addini('worker_log_file', help=log_help_text)
log_group = parser.getgroup('logging')
log_group.addoption('--worker-log-file', dest='worker_log_file', help=log_help_text)
def pytest_configure(config):
configure_logger(config)
def configure_logger(config):
if is_xdist_enabled():
log_file = config.getini('worker_log_file')
logging.basicConfig(
format=config.getini('log_file_format'),
filename=log_file.replace('%w', os.environ.get('PYTEST_XDIST_WORKER')),
level=config.getini('log_file_level')
)
def is_xdist_enabled():
return os.environ.get('PYTEST_XDIST_WORKER') is not None
The text was updated successfully, but these errors were encountered:
I am trying to get log file for each worker. I have followed #331. I have added code in conftest.py and pytest.ini file, but still separate log files are not generated. Below are the details of my files. @nbartos @nicoddemus @marcosanchotene Could someone please help me out.
Also how the value of PYTEST_XDIST_WORKER' is picked up do we need to define it somewhere. I am invoking my tests from commandline through this pytest -v -s -m "smoke or regression" -n 3 --worker-log-file Logs/pytest-%w.log TestCases/
My pytest.ini file
My conftest.py file code
The text was updated successfully, but these errors were encountered: