Skip to content
Allure report logoAllure Report
Main Navigation ModulesDocumentationStart

English

Español

English

Español

Appearance

Sidebar Navigation

Introduction

Install & Upgrade

Install for Windows

Install for macOS

Install for Linux

Install for Node.js

Upgrade Allure

Getting started

How to view a report

Improving readability of your test reports

Improving navigation in your test report

Features

Test steps

Attachments

Test statuses

Sorting and filtering

Defect categories

Visual analytics

Test stability analysis

History and retries

Timeline

Export to CSV

Export metrics

Guides

JUnit 5 parametrization

JUnit 5 & Selenide: screenshots and attachments

JUnit 5 & Selenium: screenshots and attachments

Setting up JUnit 5 with GitHub Actions

Pytest parameterization

Pytest & Selenium: screenshots and attachments

Pytest & Playwright: screenshots and attachments

Pytest & Playwright: videos

Playwright parameterization

How it works

Overview

Test result file

Container file

Categories file

Environment file

Executor file

History files

Integrations

Azure DevOps

Bamboo

GitHub Actions

Jenkins

JetBrains IDEs

TeamCity

Visual Studio Code

Frameworks

Behat

Getting started

Configuration

Reference

Behave

Getting started

Configuration

Reference

Codeception

Getting started

Configuration

Reference

CodeceptJS

Getting started

Configuration

Reference

Cucumber.js

Getting started

Configuration

Reference

Cucumber-JVM

Getting started

Configuration

Reference

Cucumber.rb

Getting started

Configuration

Reference

Cypress

Getting started

Configuration

Reference

Jasmine

Getting started

Configuration

Reference

JBehave

Getting started

Configuration

Reference

Jest

Getting started

Configuration

Reference

JUnit 4

Getting started

Configuration

Reference

JUnit 5

Getting started

Configuration

Reference

Mocha

Getting started

Configuration

Reference

Newman

Getting started

Configuration

Reference

NUnit

Getting started

Configuration

Reference

PHPUnit

Getting started

Configuration

Reference

Playwright

Getting started

Configuration

Reference

pytest

Getting started

Configuration

Reference

Pytest-BDD

Getting started

Configuration

Reference

Reqnroll

Getting started

Configuration

Reference

REST Assured

Getting started

Configuration

Robot Framework

Getting started

Configuration

Reference

RSpec

Getting started

Configuration

Reference

SpecFlow

Getting started

Configuration

Reference

Spock

Getting started

Configuration

Reference

TestNG

Getting started

Configuration

Reference

Vitest

Getting started

Configuration

Reference

WebdriverIO

Getting started

Configuration

Reference

xUnit.net

Getting started

Configuration

Reference

On this page

Allure Pytest-BDD reference ​

These are the attributes and methods that you can use to integrate your Pytest-BDD tests with Allure Report.

Parametrized tests ​

In Gherkin, a Scenario Outline (or a Scenario Template) implements the parametrized tests pattern. A scenario outline must contain an Examples table, from which Pytest-BDD loads sets of parameters, one row after another. Each set of parameters is being placed into the step declarations according to the placeholders, thus generating a new scenario based on the row. Pytest-BDD then runs each of them independently, as if it was a separate Scenario. The data can then be captured by Pytest-BDD and passed as separate arguments to the Python code.

Allure Pytest-BDD automatically recognizes this pattern. No additional configuration is required.

The example below shows a Gherkin file and a Python implementation file of a test. In this example, the four parameters for the “I enter my details...” step will be displayed in both instances of the scenario in the test report.

gherkin
Feature: User management

  Scenario Outline: Registration
    When I go to the registration form
    And I enter my details: <login>, <password>, <name>, <birthday>
    Then the profile should be created

    Examples:
      | login   | password | name     | birthday   |
      | johndoe | qwerty   | John Doe | 1970-01-01 |
      | janedoe | 123456   | Jane Doe | 1111-11-11 |
python
from pytest_bdd import given, parsers, scenario, then, when

@scenario('features/UserManagement.feature', 'Registration')
def test_parameters():
    pass

@when('I go to the registration form')
def i_go_to_registration_form():
    ...

@when(parsers.parse('I enter my details: {login}, {password}, {name}, {birthday}'))
def i_enter_my_details(login, password, name, birthday):
    ...

@then('the profile should be created')
def profile_should_be_created():
    ...

Attaching content from variables ​

  • allure.attach(body, name=None, attachment_type="text/plain", extension="attach")

Add body as an attachment to the test result under the given name (defaults to a unique pseudo-random string). The body must be of type bytes or str.

To ensure that the reader's web browser will display attachments correctly, it is recommended to specify each attachment's type. There are two ways to do this:

  • Pass the media type of the content as attachment_type and, optionally, a filename extension as extension.

    Some popular media types are image/png and image/jpeg for screenshots and other images, application/json for JSON data, and text/plain for text files. The media type affects how the data will be displayed in the test report, while the filename extension is appended to the filename when user wants to save the file.

  • Pass a value from the allure.attachment_type class as attachment_type.

    This will automatically set the media type and the appropriate filename extension.

python
import allure
import requests
from pytest_bdd import then

@then("I open labels page")
def test_labels():
    ...
    png_bytes = requests.get('https://example.com/image.png').content
    allure.attach(png_bytes, name="my-image", attachment_type=allure.attachment_type.PNG)

Reading attachments from files ​

  • allure.attach.file(source, name=None, attachment_type=None, extension=None)

Same as attach(), but the content is loaded from the existing source file.

python
import allure
from pytest_bdd import then

@then("I open labels page")
def test_labels():
    ...
    allure.attach.file('/path/to/image.png', name="my-image", attachment_type=allure.attachment_type.PNG)
Pager
Previous pageConfiguration
Next pageGetting started
Powered by

Join our newsletter

Allure TestOps
  • Overview
  • Why choose us
  • Cloud
  • Self-hosted
  • Success Stories
Company
  • Documentation
  • Blog
  • About us
  • Contact
  • Events
© 2025 Qameta Software Inc. All rights reserved.