Framework Mode - Single parameter
Folder Structure
tests/ ├── test_example.py ├── conftest.py utilities/ ├── helpers.py pytest.ini
tests/ ├── test_example.py ├── conftest.py utilities/ ├── helpers.py pytest.ini
test_example.py where test functions with single parameters are defined.Use pytest.ini to define default options like test paths and markers.
Manage environments and credentials via environment variables or fixtures in conftest.py.
Example: Use a fixture to provide a single parameter value to tests.
pytest-html for readable test summaries.Where would you add a new fixture that provides a single parameter value for multiple tests?
import pytest
@pytest.mark.parametrize('x', [2, 4])
def test_double(x):
assert x * 2 == 4import pytest
@pytest.mark.parametrize('val', 1, 2, 3)
def test_positive(val):
assert val > 0def test_is_uppercase(s):
assert s.isupper()Pass the test and this pattern moves unknown