Python/pytest: Difference between revisions

From Omnia
Jump to navigation Jump to search
No edit summary
 
(No difference)

Latest revision as of 15:41, 29 August 2022

Pytest

Looks for scripts named test_*.py or *_test.py

Setup and Teardown

import pytest

@pytest.fixture(autouse=True)
def run_before_and_after_tests(tmpdir):
    """Fixture to execute asserts before and after a test is run"""
    # Setup: fill with any logic you want

    yield # this is where the testing happens

    # Teardown : fill with any logic you want

ref: [1]