Code Monkey home page Code Monkey logo

allure-python's Introduction

Allure Pytest Adaptor

Release Status

Downloads

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

Features & Stories ========

Feature and Story can be set for test.

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:

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.

allure-python's People

Contributors

pupssman avatar mavlyutov avatar f1ashhimself avatar dchr avatar vania-pooh avatar

Watchers

James Cloos avatar Oleksii Yurchuk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.