What is the effect of adding --maxfail=2 --disable-warnings to the addopts option in pytest.ini?
Think about what --maxfail and --disable-warnings do individually.
The --maxfail=2 option tells pytest to stop testing after 2 failures. The --disable-warnings option suppresses warning messages during the test run.
Given the following pytest.ini configuration:
[pytest] addopts = -v
and a test file test_sample.py with two passing tests, what will be the output style when running pytest?
def test_one(): assert 1 == 1 def test_two(): assert 2 == 2
What does the -v option do in pytest?
The -v option increases verbosity, showing each test's name and result instead of just dots.
You have set addopts = --tb=short in pytest.ini. Which assertion correctly verifies that the traceback style is short during test failure?
def test_fail(): assert False
Check how to access the traceback style option in pytest.
The traceback style is accessed via getoption('tb'). The value should be 'short' if --tb=short is set.
Which addopts line in pytest.ini will cause a syntax error when pytest tries to parse it?
Look carefully at the spacing in the options.
Option D has a space in --disable warnings which is invalid. It should be --disable-warnings without spaces.
If addopts in pytest.ini includes --ignore=tests/integration, what will happen when you run pytest?
What does the --ignore option do in pytest?
The --ignore option tells pytest to skip the specified path during test discovery, so tests in that directory won't run.