This is readme
Last active
August 5, 2021 06:57
-
-
Save skhomuti/5e629e331c0a1a72c222da0592458f22 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from typing import Optional | |
from _pytest.config.argparsing import OptionGroup, Parser | |
from _pytest.nodes import Item | |
from _pytest.runner import CallInfo | |
from allure_commons.reporter import AllureReporter | |
from allure_pytest.listener import AllureListener | |
def allure_reporter(config) -> Optional[AllureReporter]: | |
"""Get Allure Reporter from pytest plugins""" | |
listener: AllureListener = next( | |
filter( | |
lambda plugin: (isinstance(plugin, AllureListener)), | |
dict(config.pluginmanager.list_name_plugin()).values(), | |
), | |
None, | |
) | |
return listener.allure_logger if listener else None | |
def pytest_runtest_makereport(item: Item, call: CallInfo[None]): | |
if hasattr(item, "callspec") and call.when == "setup": | |
reporter = allure_reporter(item.config) | |
latest_test = reporter.get_test(None) | |
latest_test.name = f"{latest_test.name}[{item.callspec.id}]" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import allure | |
import pytest | |
@allure.title("Some title") | |
@pytest.mark.parametrize("param", [True, False], ids=["true", "false"]) | |
def test_with_param(param): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment