---
title: Pytest configuration
description: Configuration for Allure Pytest | Change allure-results directory | Configure link patterns | Add labels for all tests
---

# Allure Pytest configuration

The [Allure Pytest](/docs/pytest/) integration provides some additional configuration options that you can pass to pytest. These options affect [how Allure Pytest collects the test results](#options-affecting-results-collection) and [how pytest itself selects which tests to run](#options-affecting-test-selection).

To pass an option, you can just add it to the command when running pytest. For example:

```bash
python -m pytest --alluredir allure-results --clean-alluredir
```

However, if you want some options to be applies for all pytest runs, add them to the pytest's [`addopts`](https://docs.pytest.org/en/latest/reference/reference.html#confval-addopts) configuration option. It must be declared in the project's configuration file.

**pyproject.toml:**
```toml
[tool.pytest.ini_options]
addopts = [
    "--alluredir", "allure-results",
    "--clean-alluredir"
]
```

**pytest.ini:**
```ini
[pytest]
addopts = --alluredir allure-results
          --clean-alluredir
```

## Options affecting results collection

### --alluredir ⟨DIRECTORY⟩

Path to the directory where Allure Pytest will save the test results, see [How it works](/docs/how-it-works/). If the directory does not exist, it will be created.

### --clean-alluredir

If set, the directory specified by [`--alluredir`](#--alluredir-directory) will be cleaned before generating new test results.

By default, the existing data is kept intact, which allows combining results of multiple test runs into a single test report.

### --allure-no-capture

If set, Allure Pytest will not automatically produce the `stdout`, `stderr` and `log` attachments, described in [Attach screenshots and other files](/docs/pytest/#attach-screenshots-and-other-files).

### --allure-link-pattern ⟨TYPE⟩:⟨PATTERN⟩

Define a **link pattern** — a template that can be used to construct full URLs from short identifiers, see the [reference](/docs/pytest-reference/#link).

The option accepts two values, separated by a colon.

- `TYPE` is an arbitrary string identifier.
- `PATTERN` is a string containing `{}` at the position where the identifier should be placed.

The given `PATTERN` will be applied when processing any link of the given `TYPE`. You can use the option multiple times, thus defining multiple link patterns for different link types.

For example, here's a way to define a link pattern for issues in a GitHub repository:

```bash
python -m pytest --allure-link-pattern issue:https://github.com/allure-framework/allure-python/issues/{}
```

## Options affecting test selection

Each one of these options, except for [`--inversion`](#--inversion), accepts a comma-separated list of values that narrow down the selection of tests pytest should run. When two or more of such options are used together, pytest will run tests matching any of the conditions.

Warning:
The options don't work with the metadata added dynamically inside the code of the tests, see [Specify description, links and other metadata](/docs/pytest/#specify-description-links-and-other-metadata).

### --allure-severities ⟨SEVERITY1⟩,⟨SEVERITY2⟩,...

Only run tests that have one of the specified **severity** values, see [Specify description, links and other metadata](/docs/pytest/#specify-description-links-and-other-metadata).

### --allure-epics ⟨EPIC1⟩,⟨EPIC2⟩,...

Only run tests that have one of the specified **epic** values, see [Behavior-based hierarchy](/docs/v2/navigation/#behavior-based-hierarchy).

### --allure-features ⟨FEATURE1⟩,⟨FEATURE2⟩,...

Only run tests that have one of the specified **feature** values, see [Behavior-based hierarchy](/docs/v2/navigation/#behavior-based-hierarchy).

### --allure-stories ⟨STORY1⟩,⟨STORY2⟩,...

Only run tests that have one of the specified **story** values, see [Behavior-based hierarchy](/docs/v2/navigation/#behavior-based-hierarchy).

### --allure-ids ⟨ID1⟩,⟨ID2⟩,...

Only run tests that have one of the specified **IDs**, see [Specify description, links and other metadata](/docs/pytest/#specify-description-links-and-other-metadata).

### --allure-label ⟨LABEL1⟩=⟨VALUE1⟩,⟨LABEL2⟩=⟨VALUE2⟩,...

Only run tests that have one of the specified **labels**, see [Specify description, links and other metadata](/docs/pytest/#specify-description-links-and-other-metadata).

### --inversion

If set, pytest will only run the tests that **do not** match the conditions specified by other arguments or the test plan.
