Test Overview
This test checks if pytest correctly reads configuration from pyproject.toml to set test markers and options. It verifies that a test marked as smoke runs and passes.
This test checks if pytest correctly reads configuration from pyproject.toml to set test markers and options. It verifies that a test marked as smoke runs and passes.
import pytest @pytest.mark.smoke def test_example(): assert 1 + 1 == 2 # Run command: # pytest -m smoke # pyproject.toml content: # [tool.pytest.ini_options] # markers = ["smoke: mark test as smoke test"] # addopts = "-m smoke"
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test runner starts pytest | pytest reads pyproject.toml configuration file | — | PASS |
| 2 | pytest applies ini_options from pyproject.toml, enabling 'smoke' marker and '-m smoke' option | pytest is configured to run only tests marked with 'smoke' | — | PASS |
| 3 | pytest discovers test_example function | test_example is marked as 'smoke' | — | PASS |
| 4 | pytest runs test_example | test_example executes assert 1 + 1 == 2 | assert 2 == 2 | PASS |
| 5 | pytest reports test_example passed with 'smoke' marker | Test report shows 1 passed test with smoke marker | test count and marker correctness | PASS |
pyproject.toml file in pytest?pyproject.tomlpyproject.toml for pytest?[tool.pytest] in pyproject.toml.testpaths and it expects a list of strings, e.g., ["tests"].pyproject.toml snippet:[tool.pytest] markers = ["slow: marks tests as slow"] addopts = "-v --maxfail=2"
pytest?addopts settings-v flag makes output verbose; --maxfail=2 stops tests after 2 failures.markers settingslow marker means pytest recognizes it and can filter or mark tests accordingly.pyproject.toml:[tool.pytest] markers = "slow: marks slow tests" addopts = -v
integration_tests folder and recognize a custom marker api. Which pyproject.toml configuration is correct?testpaths as a list under [tool.pytest] to specify test folders.Pass the test and this pattern moves unknown