Bug 1340092 - [mozlog] Add metadata from pytest-metadata plugin if installed to suite_start. r=ahal

If the optional pytest-metadata plugin is installed, add the metadata as run_info when logging the suite_start to give additional context to the results.

MozReview-Commit-ID: 1MeXZTmzvyp

--HG--
extra : rebase_source : e5f9fd4fddc2bbe2cc8fbf76b4f2a5034a14e722
This commit is contained in:
Dave Hunt 2017-02-16 01:54:25 +00:00
Родитель d5a8749441
Коммит d64e51a5f5
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -41,7 +41,10 @@ class MozLog(object):
if not self._started:
# As this is called for each node when using pytest-xdist, we want
# to avoid logging multiple suite_start messages.
self.logger.suite_start(tests=tests, time=self.start_time)
self.logger.suite_start(
tests=tests,
time=self.start_time,
run_info=self.run_info)
self._started = True
def pytest_configure(self, config):
@ -52,6 +55,7 @@ class MozLog(object):
def pytest_sessionstart(self, session):
'''Called before test collection; records suite start time to log later'''
self.start_time = int(time.time() * 1000) # in ms for Mozlog compatibility
self.run_info = getattr(session.config, '_metadata', None)
def pytest_collection_finish(self, session):
'''Called after test collection is completed, just before tests are run (suite start)'''