Skip to content

Instantly share code, notes, and snippets.

@skhomuti
Last active August 5, 2021 06:57
Show Gist options
  • Save skhomuti/5e629e331c0a1a72c222da0592458f22 to your computer and use it in GitHub Desktop.
Save skhomuti/5e629e331c0a1a72c222da0592458f22 to your computer and use it in GitHub Desktop.

This is readme

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}]"
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