Skip to content

Commit

Permalink
record start_time property workaround for pytest-dev/pytest#7767
Browse files Browse the repository at this point in the history
  • Loading branch information
rplevka authored and mshriver committed Nov 4, 2020
1 parent 922947a commit 853e56b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/foreman/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pytest_reportportal import RPLogger, RPLogHandler
except ImportError:
pass
from _pytest.junitxml import xml_key
from robottelo.config import settings
from robottelo.decorators import setting_is_set

Expand Down Expand Up @@ -44,7 +45,13 @@ def pytest_report_header(config):
shared_function_enabled, scope, storage
)
)

# workaround for https://github.com/pytest-dev/pytest/issues/7767
# remove if resolved and set autouse=True for record_testsuite_timestamp_xml fixture
if config.pluginmanager.hasplugin("junitxml"):
now = datetime.datetime.utcnow()
xml = config._store.get(xml_key, None)
if xml:
xml.add_global_property('start_time', now)
return messages


Expand Down Expand Up @@ -137,7 +144,7 @@ def pytest_collection_modifyitems(session, items, config):
items[:] = [item for item in items if item not in deselected_items]


@pytest.fixture(autouse=True, scope="session")
@pytest.fixture(autouse=False, scope="session")
def record_testsuite_timestamp_xml(record_testsuite_property):
now = datetime.datetime.utcnow()
record_testsuite_property("start_time", now.strftime("%Y-%m-%dT%H:%M:%S"))
Expand Down

0 comments on commit 853e56b

Please sign in to comment.