Skip to main content
Help us improve Python packaging – donate today!

Plugin for py.test to generate allure xml reports

Project Description

Allure Pytest Adaptor
=====================

.. image:: https://pypip.in/v/pytest-allure-adaptor/badge.png
:alt: Release Status
:target: https://pypi.python.org/pypi/pytest-allure-adaptor
.. image:: https://pypip.in/d/pytest-allure-adaptor/badge.png
:alt: Downloads
:target: https://pypi.python.org/pypi/pytest-allure-adaptor

This repository contains a plugin for ``py.test`` which automatically prepares input data used to generate ``Allure Report``.

Usage
=====
.. code:: python

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:

.. code:: python

pytest_plugins = 'allure.pytest_plugin',\


Advanced usage
==============

Attachments
===========

To attach some content to test report:

.. code:: python

import allure

def test_foo():
allure.attach('my attach', 'Hello, World')


Steps
=====

To divide a test into steps:

.. code:: python

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:

.. code:: python

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``:

.. code:: python

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:

.. code:: python

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:

.. code:: rest

py.test my_tests/ --allure_severities=critical,blocker

Features & Stories
========

Feature and Story can be set for test.

.. code:: python

import allure


@allure.feature('Feature1')
@allure.story('Story1')
def test_minor():
assert False


@allure.feature('Feature2')
@allure.story('Story2', 'Story3')
@allure.story('Story4')
class TestBar:

# will have 'Feature2 and Story2 and Story3 and Story4'
def test_bar(self):
pass


To run tests by Feature or Story:

.. code:: rest

py.test my_tests/ --allure_features=feature1,feature2
py.test my_tests/ --allure_features=feature1,feature2 --allure_stories=story1,story2

Extending
=========

Use ``allure.common.AllureImpl`` class to bind your logic to this adapter.

Release history Release notifications

History Node

1.7.10

History Node

1.7.9

History Node

1.7.8

History Node

1.7.7

History Node

1.7.6

History Node

1.7.5

History Node

1.7.4

History Node

1.7.4b0

History Node

1.7.3

History Node

1.7.2

History Node

1.7.1

History Node

1.7.0

History Node

1.6.8

History Node

1.6.7

History Node

1.6.6

History Node

1.6.5

History Node

1.6.4

History Node

1.6.3

History Node

1.6.2

History Node

1.6.1

History Node

1.6.0

History Node

1.5.4

History Node

1.5.3

History Node

1.5.2

History Node

1.5.1

History Node

1.5.0

History Node

1.4.1

This version
History Node

1.4.0

History Node

1.3.9

History Node

1.3.8

History Node

1.3.7

History Node

1.3.6

History Node

1.3.5

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
pytest-allure-adaptor-1.4.0.tar.gz (14.5 kB) Copy SHA256 hash SHA256 Source None Aug 11, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page