Plugin for py.test to generate allure xml reports
Project description
Allure Pytest Adaptor
This repository contains a plugin for py.test which automatically prepares input data used to generate Allure Report.
Usage
py.test --alluredir [path_to_report_dir]
# WARNING [path_to_report_dir] will be purged at first run
This plugin gets automatically connected to py.test via entry point if installed.
Connecting to IDE:
pytest_plugins = 'allure.pytest_plugin',\
Advanced usage
Attachments
To attach some content to test report:
import allure
def test_foo():
allure.attach('my attach', 'Hello, World')
Steps
To divide a test into steps:
import pytest
def test_foo():
with pytest.allure.step('step one'):
# do stuff
with pytest.allure.step('step two'):
# do more stuff
Can also be used as decorators. By default step name is generated from method name:
import pytest
@pytest.allure.step
def make_test_data_foo():
# do stuff
def test_foo():
assert make_some_data_foo() is not None
@pytest.allure.step('make_some_data_foo')
def make_some_data_bar():
# do another stuff
def test_bar():
assert make_some_data_bar() is not None
Steps can also be used without pytest. In that case instead of pytest.allure.step simply use allure.step:
import allure
@allure.step('some operation')
def do_operation():
# do stuff
Steps support is limited when used with fixtures.
Severity
Any test, class or module can be marked with different severity:
import pytest
@pytest.allure.severity(pytest.allure.severity_level.MINOR)
def test_minor():
assert False
@pytest.allure.severity(pytest.allure.severity_level.CRITICAL)
class TestBar:
# will have CRITICAL priority
def test_bar(self):
pass
# will have BLOCKER priority via a short-cut decorator
@pytest.allure.BLOCKER
def test_bar(self):
pass
To run tests with concrete priority:
py.test my_tests/ --allure_severities=critical,blocker
Extending
Use allure.common.AllureImpl class to bind your logic to this adapter.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for pytest-allure-adaptor-1.3.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b90a2c20d8686f744941f451b65e69d68e6c703d411b708db4e5bea9ad27cfbd |
|
MD5 | fbca7b606d7b4b73fcaba1a5bff370a7 |
|
BLAKE2b-256 | c4f1b1e5d813826f8c032bf3f6b73d644859cf56f20f15ad0477ce6d37d9459f |