Recall & Review
beginner
What is PyTest used for?
PyTest is a tool to write and run tests for Python code. It helps check if your code works as expected.
Click to reveal answer
beginner
How do you name a test function in PyTest?
Test functions should start with the word
test_. For example, def test_addition():.Click to reveal answer
beginner
What does an assertion do in a PyTest test?
An assertion checks if a condition is true. If it is false, the test fails and shows an error.
Click to reveal answer
beginner
How do you run tests using PyTest?
You run tests by typing
pytest in the command line inside your project folder.Click to reveal answer
beginner
What is the output when a PyTest test passes?
PyTest shows a dot
. for each passing test and a summary saying how many tests passed.Click to reveal answer
Which prefix should a PyTest test function have?
✗ Incorrect
PyTest recognizes test functions by the prefix
test_.What happens if an assertion in a PyTest test fails?
✗ Incorrect
An assertion failure means the test did not meet the expected condition, so it fails.
How do you run all tests in a folder using PyTest?
✗ Incorrect
Typing
pytest in the command line runs all tests it finds in the folder.What symbol does PyTest show for a passing test?
✗ Incorrect
PyTest shows a dot
. for each test that passes.Which of these is a valid simple PyTest test function?
✗ Incorrect
Only functions starting with
test_ are recognized as tests by PyTest.Explain how to write and run your first test using PyTest.
Think about the steps from writing code to seeing the test result.
You got /4 concepts.
Describe what happens when a PyTest test passes and when it fails.
Focus on the test output symbols and messages.
You got /3 concepts.