This article describes the Python Automation test run from the command line test case with verbosity, share to everyone for your reference. Specific as follows:
The instance file recipe3.py is as follows:
Class Romannumeralconverter (object): def __init__ (self, roman_numeral): self.roman_numeral = roman_numeral Self.digit_map = {"M": +, "D": +, "C": +, "L": +, "X": Ten, " V": 5, "I": 1} def convert_to_decimal (self): val = 0 for char in self.roman_numeral: val + = Self.digit_map[char] return val import unittest Class Romannumeralconvertertest (UnitTest. TestCase): def Test_parsing_millenia (self): value = Romannumeralconverter ("M") self.assertequals ( Value.convert_to_decimal () def Test_parsing_century (self): "This is a error test case" Value = Romannumeralconverter ("C") Self.assertequals (Ten, Value.convert_to_decimal ()) if __name__ = = "__ main__ ": suite = UnitTest. Testloader (). Loadtestsfromtestcase (romannumeralconvertertest) unittest. Texttestrunner (verbosity=2). Run (Suite)
The results of the operation are as follows:
This is what the test case fails to look like.
Hopefully this article will help you with Python programming.