Skip to main content

Pytest plugin for sequencing markers for execution of tests

Project description

Pytest Marker Sequence

This plugin helps you sequence your markers in pytest.
We mark our tests with different markers, say like nightly, sanity, stress etc. If we wish to sequence these markers for execution of our tests, we can sequence them in pytest.ini itself as mentioned below.

Installation

  • Plugin is available on pypi.org as pip installable.
  • Install by pip command as
    pip install pytest-sequence-markers
    

Editing pytest.ini

  • pytest.ini is a configuration file for pytest.
  • For sequencing the markers, add a section named test_execution_sequence in pytest.ini
  • Add a key named marker_sequence and mention the sequence of the markers you want.
[pytest]
markers = sanity: Sanity Tests
    nightly: Nightly Tests
    release: Release Tests
    negative: Negative Tests
[test_execution_sequence]
marker_sequence = sanity, negative, nightly, release
  • The sequence of markers you specify comma separated in the ini file, tests will be executed in that sequence only

Example

  • Edit the pytest.ini as mentioned above and mention your own sequence with own markers
  • Add a test file containing all pytest tests
import pytest


@pytest.mark.sanity
def test_sanity():
    pass

@pytest.mark.release
def test_release():
    pass


@pytest.mark.negative
def test_negative():
    pass

@pytest.mark.nightly
def test_nightly():
    pass

@pytest.mark.nightly
def test_nightly2():
    pass
  • Execute the test with pytest command
$ pytest -sv
========================================================== test session starts ==========================================================
platform linux -- Python 3.8.10, pytest-7.3.1, pluggy-1.0.0 -- /home/siddhesh/py38/bin/python
cachedir: .pytest_cache
rootdir: /home/siddhesh/plugin_test
configfile: pytest.ini
plugins: sequence-markers-0.0.1
collecting ... I am in local one
collected 5 items                                                                                                                                                                                                                                          

tests/test_me.py::test_sanity PASSED
tests/test_me.py::test_negative PASSED
tests/test_me.py::test_nightly PASSED
tests/test_me.py::test_nightly2 PASSED
tests/test_me.py::test_release PASSED

========================================================== 5 passed in 0.01s ==========================================================

Project details


Download files

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

Source Distribution

pytest_sequence_markers-0.0.2.tar.gz (3.1 kB view details)

Uploaded Source

File details

Details for the file pytest_sequence_markers-0.0.2.tar.gz.

File metadata

  • Download URL: pytest_sequence_markers-0.0.2.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for pytest_sequence_markers-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5dde177e57ba1ee882aa172374e36844c06148eaa12b464482a4c8b0ddce9e3b
MD5 6c71bdec538930ada0bc4e00f222b34e
BLAKE2b-256 5d2997a7d1e1860737093933aecdcc3c769d9b1c42f0cb5809b2e7607a33cd54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page