Framework Mode - Approximate comparisons (pytest.approx)
Folder Structure
test_project/ ├── tests/ │ ├── test_math_operations.py │ └── test_utils.py ├── src/ │ └── math_functions.py ├── conftest.py ├── pytest.ini └── requirements.txt
test_project/ ├── tests/ │ ├── test_math_operations.py │ └── test_utils.py ├── src/ │ └── math_functions.py ├── conftest.py ├── pytest.ini └── requirements.txt
test_math_operations.py where pytest.approx is used for approximate value assertions.src/ folder, e.g., math functions to be tested.conftest.py for shared fixtures and setup.pytest.ini to configure pytest options.[pytest]
addopts = -v --tb=short
markers =
slow: marks tests as slow
pytest command line options to switch test parameters if needed.pytest.approx with relative or absolute tolerance directly in tests, no global config needed.-v option for clear pass/fail output.--junitxml=report.xml for CI dashboards.pytest-html for human-readable HTML reports.pytest.approx for floating-point comparisons: Avoid exact equality to handle rounding errors.rel or abs parameters in approx to control precision.assert result == pytest.approx(expected, rel=1e-6) for clarity.conftest.py fixtures.Where in this folder structure would you add a new test file to verify approximate comparisons for a new math function?