py.test - Is there a way to find out which pytest-xdist gateway is running? -
i create separate log file each subprocess/gateway spawned pytest-xdist. there elegant way of finding out in subprocess/gateway pytest in? i'm configuring root logger session scoped fixture located in conftest.py
, this:
@pytest.fixture(scope='session', autouse=true) def setup_logging(): logger = logging.getlogger(__name__) logger.setlevel(logging.info) fh = logging.filehandler('xdist.log') fh.setlevel(logging.info) formatter = logging.formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') fh.setformatter(formatter) logger.addhandler(fh)
it great if add together prefix log file name based on gateway number, e.g:
fh = logging.filehandler('xdist_gateway_%s.log' % gateway_number)
without each gateway utilize same log , logs messy. know can add together time stamp filename. doesn't allow me distinguish file gateway.
i found out can access gateway id in next way:
slaveinput = getattr(session.config, "slaveinput", none) if slaveinput: gatewayid = slaveinput['slaveid']
of course of study need in place can access session.config object.
py.test
No comments:
Post a Comment