Challenge - 5 Problems
Command-line Options Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of pytest with verbose option
What is the output behavior when running
pytest -v on a test file with 3 passing tests?PyTest
def test_one(): assert 1 == 1 def test_two(): assert 2 == 2 def test_three(): assert 3 == 3
Attempts:
2 left
💡 Hint
The
-v option stands for verbose output.✗ Incorrect
The
-v option makes pytest show each test's name and result instead of just dots.❓ assertion
intermediate2:00remaining
Correct assertion for exit code with pytest --maxfail=1
You run
pytest --maxfail=1 on a test suite with multiple failing tests. Which assertion correctly checks that pytest stopped after the first failure?PyTest
import subprocess result = subprocess.run(['pytest', '--maxfail=1'], capture_output=True, text=True) exit_code = result.returncode
Attempts:
2 left
💡 Hint
pytest returns 0 if all tests pass, 1 if any test fails.
✗ Incorrect
pytest returns exit code 1 when tests fail, including when stopped by --maxfail.
❓ locator
advanced2:00remaining
Best locator for pytest to run tests in a specific directory
You want to run pytest only on tests inside the
tests/integration folder. Which command correctly locates and runs those tests?Attempts:
2 left
💡 Hint
pytest accepts folder paths as positional arguments to run tests there.
✗ Incorrect
Passing the folder path as an argument runs tests only in that folder.
🔧 Debug
advanced2:00remaining
Identify the error in pytest command usage
Which pytest command will cause an error when trying to run tests with keyword expression
login and not slow?Attempts:
2 left
💡 Hint
Shell interprets unquoted words separately.
✗ Incorrect
Option A lacks quotes, so shell treats 'and' and 'not' as separate commands causing error.
❓ framework
expert2:00remaining
Effect of pytest --tb=short option on test failure output
What is the effect of running pytest with the
--tb=short option on the traceback shown for failed tests?Attempts:
2 left
💡 Hint
The
--tb option controls traceback verbosity.✗ Incorrect
The
--tb=short option shortens the traceback to the last call and error message only.