Step 1: Check method definitions inside test classes
Instance methods inside test classes must have self as first parameter.
Step 2: Identify the error
test_add is missing self, so pytest will error or skip it.
Final Answer:
test_add is missing the self parameter -> Option D
Quick Check:
Test methods in classes need self [OK]
Hint: Test methods in classes must include self parameter [OK]
Common Mistakes:
Omitting self in test methods
Thinking class names cannot start with Test
Removing assertions from test methods
5. You want to run only tests related to the login feature in your pytest suite. You have marked tests with @pytest.mark.login and grouped some inside a class TestLogin. Which command will correctly run all login tests, including those inside the class?
hard
A. pytest -k login
B. pytest -m login
C. pytest --group=login
D. pytest --run-login
Solution
Step 1: Understand pytest options for running grouped tests
pytest uses -m to run tests marked with a specific marker like 'login'.
Step 2: Identify correct command
pytest -m login runs all tests marked with @pytest.mark.login, including those inside classes.
Final Answer:
pytest -m login -> Option B
Quick Check:
-m runs marked tests, -k filters by test name [OK]
Hint: Use -m with marker name to run grouped tests [OK]
Common Mistakes:
Using -k which filters by test name, not marker
Using nonexistent options like --group or --run-login
Assuming class name filters tests automatically
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.