34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
import sys
|
|
|
|
current_file_path = os.path.abspath(__file__)
|
|
project_root = os.path.abspath(os.path.join(os.path.dirname(current_file_path), '../../../..'))
|
|
if project_root not in sys.path:
|
|
sys.path.insert(0, project_root)
|
|
|
|
try:
|
|
import allure_pytest.listener
|
|
except ImportError:
|
|
allure_pytest = None
|
|
|
|
|
|
def _allure_test_fixtures_compatible(item):
|
|
fixturemanager = item.session._fixturemanager
|
|
fixturedefs = []
|
|
|
|
if hasattr(item, "_request") and hasattr(item._request, "fixturenames"):
|
|
for name in item._request.fixturenames:
|
|
try:
|
|
fixturedefs_pytest = fixturemanager.getfixturedefs(name, item)
|
|
except AttributeError:
|
|
fixturedefs_pytest = fixturemanager.getfixturedefs(name, item.nodeid)
|
|
if fixturedefs_pytest:
|
|
fixturedefs.extend(fixturedefs_pytest)
|
|
|
|
return fixturedefs
|
|
|
|
|
|
if allure_pytest is not None:
|
|
allure_pytest.listener._test_fixtures = _allure_test_fixtures_compatible
|