Bird
0
0

What is wrong with this pytest test class? class TestSample: def test_one(): assert True def test_two(self): assert True

medium📝 Debug Q7 of 15
Selenium Python - Test Framework Integration (pytest)
What is wrong with this pytest test class? class TestSample: def test_one(): assert True def test_two(self): assert True
AClass must be named 'Tests' to be discovered.
Btest_one is missing the self parameter.
CTest methods must be decorated with @pytest.mark.test.
DClass name must inherit from unittest.TestCase.
Step-by-Step Solution
Solution:
  1. Step 1: Check method signatures in pytest classes

    Instance methods must have 'self' as first parameter; test_one lacks it.
  2. Step 2: Verify other options

    Pytest does not require inheritance or decorators for discovery; class name can be any starting with 'Test'.
  3. Final Answer:

    test_one is missing the self parameter. -> Option B
  4. Quick Check:

    Instance methods need self parameter [OK]
Quick Trick: Always include self in test class methods [OK]
Common Mistakes:
  • Omitting self in method definitions
  • Thinking pytest requires unittest inheritance
  • Assuming decorators are mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes