Skip to main content

Control your tests flow

Project description

pytest-directives

Control your tests flow.

Provides directives, that makes process of running tests clear and controllable.

Install:

pip install pytest-directives

Example:

Three main directives

from pytest_directives import sequence, chain, parallel

sequence()  # run items one by one; ignore errors

chain()     # run items one by one; stop when first fail found

parallel()  # run items in parallel; ignore errors

How to run directives

from pytest_directives import sequence

# just import your tests
from tests import test_file_1, test_file_2, test_file_3


# define order in `flow`
sequence_flow = sequence(
    test_file_1,
    test_file_2,
    test_file_3
)

# add some options to pytest
pytest_run_args = (
    "-v",
    "--alluredir=./allure-results",
)

import asyncio
# start your flow
asyncio.run(
    sequence_flow.run(*pytest_run_args)
)

Combine directives in flows

from pytest_directives import sequence, chain, parallel


abstract_flow = sequence(
    chain(
        chain(
            # prepare infrastructure or tests environment
        ),
        # if infrastructure failed, exit from here
        parallel(
            # run tests in parallel to increase speed of testing
        )
    ),
    sequence(
        # do some important stuff at the end of tests,
        #   like collect logs, metrics or just cleanup environment
    )
)

smoke_flow = sequence(
    chain(
        chain(
            prepare_environment(),
            check_infrastructure_health()
        ),
        parallel(
            run_test_group_a(),
            run_test_group_B(),
            run_api_tests()
        ),
    ),
    sequence(
        collect_logs(),
        generate_report(),
        cleanup_environment()
    )
)

Features

  • Can run tests by import package, module, function, class or method
  • Run pytest in separate process (say no to sharing fixture) by asyncio.create_subprocess_exec
  • Combine directives and implement your tests flow as you need

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_directives-0.0.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_directives-0.0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_directives-0.0.1.tar.gz.

File metadata

  • Download URL: pytest_directives-0.0.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.17

File hashes

Hashes for pytest_directives-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d439c1ca05859e21c2e64efed1242c968159c1aa0a9613be38214c3000c5430a
MD5 647d0752d38c104b5767600f2cf88161
BLAKE2b-256 0e5f5027d86b38f2a06d8270676206550aa3bfb3e54b0fb3c86fcb66671ff5c0

See more details on using hashes here.

File details

Details for the file pytest_directives-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_directives-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 65106c3d8a636aeab8780def49855640e21610a53262819c86ca33b90a5ae2ac
MD5 6b582d1cdf893e66e3b2794fbef0c3cb
BLAKE2b-256 04a3a498425c73e03fa5fd0f9934ba60bb24d7d148e2fc2a4d94f205ad0dee00

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