Recall & Review
beginner
What does the assertion
assert a == b check in pytest?It checks if the value of
a is equal to the value of b. If they are equal, the test passes; if not, it fails.Click to reveal answer
beginner
How do you assert that two values are not equal in pytest?
Use
assert a != b to check that a and b are different. The test passes if they are not equal.Click to reveal answer
intermediate
Why is it better to use
assert a == b instead of if a != b: raise AssertionError in pytest?Because
assert statements are simpler, clearer, and pytest shows detailed error messages automatically when assertions fail.Click to reveal answer
beginner
What happens if an equality assertion fails in pytest?
The test stops and pytest reports a failure showing the values of both sides to help you understand why they differ.
Click to reveal answer
intermediate
Can you compare complex data types like lists or dictionaries using equality assertions in pytest?
Yes, pytest can compare lists, dictionaries, and other data types using
assert a == b. It checks if their contents are the same.Click to reveal answer
What does
assert x != y check in pytest?✗ Incorrect
The assertion
assert x != y passes only if x and y are not equal.If
assert a == b fails, what does pytest show?✗ Incorrect
Pytest shows an error message with the actual values of a and b to help debug.
Which is the best way to check equality in pytest?
✗ Incorrect
Using
assert a == b is simple and integrates well with pytest reporting.Can pytest compare two dictionaries with
assert dict1 == dict2?✗ Incorrect
Pytest compares dictionaries by checking if all keys and values match.
What does
assert a != b do if a and b are equal?✗ Incorrect
The assertion fails because it expects a and b to be different.
Explain how to use pytest assertions to check if two values are equal or not equal.
Think about simple assert statements for equality and inequality.
You got /4 concepts.
Describe what happens when an equality assertion fails in pytest and why this is helpful.
Consider how pytest reports assertion failures.
You got /4 concepts.