|
9 | 9 | from pytest_reportportal import RPLogger, RPLogHandler
|
10 | 10 | except ImportError:
|
11 | 11 | pass
|
| 12 | +from _pytest.junitxml import xml_key |
12 | 13 | from robottelo.config import settings
|
13 | 14 | from robottelo.decorators import setting_is_set
|
14 | 15 |
|
| 16 | +FMT_XUNIT_TIME = "%Y-%m-%dT%H:%M:%S" |
15 | 17 |
|
16 | 18 | def log(message, level="DEBUG"):
|
17 | 19 | """Pytest has a limitation to use logging.logger from conftest.py
|
@@ -45,7 +47,13 @@ def pytest_report_header(config):
|
45 | 47 | shared_function_enabled, scope, storage
|
46 | 48 | )
|
47 | 49 | )
|
48 |
| - |
| 50 | + # workaround for https://github.com/pytest-dev/pytest/issues/7767 |
| 51 | + # remove if resolved and set autouse=True for record_testsuite_timestamp_xml fixture |
| 52 | + if config.pluginmanager.hasplugin("junitxml"): |
| 53 | + now = datetime.datetime.utcnow() |
| 54 | + xml = config._store.get(xml_key, None) |
| 55 | + if xml: |
| 56 | + xml.add_global_property('start_time', now.strftime(FMT_XUNIT_TIME)) |
49 | 57 | return messages
|
50 | 58 |
|
51 | 59 |
|
@@ -139,13 +147,13 @@ def pytest_collection_modifyitems(session, items, config):
|
139 | 147 | items[:] = [item for item in items if item not in deselected_items]
|
140 | 148 |
|
141 | 149 |
|
142 |
| -@pytest.fixture(autouse=True, scope="session") |
| 150 | +@pytest.fixture(autouse=False, scope="session") |
143 | 151 | def record_testsuite_timestamp_xml(record_testsuite_property):
|
144 | 152 | now = datetime.datetime.utcnow()
|
145 |
| - record_testsuite_property("start_time", now.strftime("%Y-%m-%dT%H:%M:%S")) |
| 153 | + record_testsuite_property("start_time", now.strftime(FMT_XUNIT_TIME)) |
146 | 154 |
|
147 | 155 |
|
148 | 156 | @pytest.fixture(autouse=True, scope="function")
|
149 | 157 | def record_test_timestamp_xml(record_property):
|
150 | 158 | now = datetime.datetime.utcnow()
|
151 |
| - record_property("start_time", now.strftime("%Y-%m-%dT%H:%M:%S")) |
| 159 | + record_property("start_time", now.strftime(FMT_XUNIT_TIME)) |
0 commit comments