pyproject.toml configuration, what will pytest discover and run?[tool.pytest.ini_options] testpaths = ["tests/integration", "tests/unit"]
testpaths option limits where pytest looks for tests.The testpaths setting in pyproject.toml tells pytest to only look for tests inside the specified folders. Here, only 'tests/integration' and 'tests/unit' are included.
capsys?def greet(): print("Hello World") def test_greet(capsys): greet() captured = capsys.readouterr() # Which assertion below is correct?
When using capsys, captured.out contains stdout including newlines. The print function adds a newline, so the output ends with '\n'.
pyproject.toml snippet correctly registers a custom marker named 'slow' with a description?The markers option expects a list of strings, each string describing a marker name and its purpose separated by a colon.
testpaths = ["tests"] in pyproject.toml, but pytest does not find tests in tests/api. What is the most likely cause?Pytest looks for test files matching patterns like 'test_*.py' or '*_test.py'. If files in 'tests/api' do not follow this, pytest ignores them even if the folder is included.
pyproject.toml snippet, what is the effect of the addopts option when running pytest?[tool.pytest.ini_options]
addopts = "-v --maxfail=2"
--maxfail option limits how many failures stop the test run.The addopts option adds command-line arguments to every pytest run. Here, -v enables verbose output, and --maxfail=2 stops testing after two failures.
