Python/pytest

From Omnia
(Redirected from Pytest)
Jump to navigation Jump to search

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]