Bird
0
0

What will be the output when running this test code snippet?

medium📝 Predict Output Q13 of 15
Selenium Python - Test Framework Integration (pytest)
What will be the output when running this test code snippet?
import unittest

class MyTest(unittest.TestCase):
    def test_pass(self):
        self.assertEqual(2 + 2, 4)

    def test_fail(self):
        self.assertTrue(False)

if __name__ == '__main__':
    unittest.main(exit=False)
ABoth tests pass
BOne test passes, one test fails
CBoth tests fail
DSyntax error occurs
Step-by-Step Solution
Solution:
  1. Step 1: Analyze test_pass method

    assertEqual(2 + 2, 4) is True, so test_pass passes.
  2. Step 2: Analyze test_fail method

    assertTrue(False) fails, so test_fail fails.
  3. Final Answer:

    One test passes, one test fails -> Option B
  4. Quick Check:

    One True, one False assertion = One test passes, one test fails [OK]
Quick Trick: Check each assertion's truth to predict pass/fail [OK]
Common Mistakes:
  • Assuming all tests pass
  • Ignoring assertTrue(False) fails
  • Expecting syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes