Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to run pytest from the command line.
PyTest
pytest [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using options that do not exist like --run or --test.
✗ Incorrect
The --help option shows help information about pytest commands.
2fill in blank
mediumComplete the command to run tests in a specific file named test_sample.py.
PyTest
pytest [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect filenames that do not exist.
✗ Incorrect
To run tests in a specific file, provide the exact filename to pytest.
3fill in blank
hardFix the error in the command to run pytest with verbose output.
PyTest
pytest [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using long or incorrect option names like --verbose or -verbose-output.
✗ Incorrect
The correct short option for verbose mode in pytest is -v.
4fill in blank
hardFill both blanks to run pytest and stop after first failure with detailed output.
PyTest
pytest [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
--maxfail=1 instead of -x for stopping on failure.✗ Incorrect
-v enables verbose output and -x stops after the first failure.
5fill in blank
hardFill all three blanks to run pytest on a directory tests, show detailed output, and stop after 2 failures.
PyTest
pytest [1] [2] [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
-x instead of --maxfail=2 to stop after two failures.✗ Incorrect
Run tests in tests directory, verbose output with -v, and stop after 2 failures using --maxfail=2.