Bird
0
0

What is wrong with this code snippet for generating an HTML report?

medium📝 Debug Q7 of 15
Selenium Python - Test Framework Integration (pytest)
What is wrong with this code snippet for generating an HTML report?
import unittest
from htmltestrunner import HTMLTestRunner

class MyTests(unittest.TestCase):
    def test_example(self):
        self.assertEqual(1, 1)

suite = unittest.TestLoader().loadTestsFromTestCase(MyTests)
runner = HTMLTestRunner(output=123)
runner.run(suite)
AMyTests is not defined before use
BThe output parameter must be a string, not an integer
CHTMLTestRunner does not accept an output parameter
DThe runner.run() method is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Check the output parameter type

    The output parameter expects a string folder name, but 123 is an integer, causing a type error.
  2. Step 2: Confirm other code parts

    The test case class is properly defined, and the runner.run() method has correct syntax with parentheses.
  3. Final Answer:

    The output parameter must be a string, not an integer -> Option B
  4. Quick Check:

    Output folder must be string [OK]
Quick Trick: Output folder name must be a string [OK]
Common Mistakes:
  • Passing non-string output
  • Thinking HTMLTestRunner does not accept output param
  • Misreading method call syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Python Quizzes