How to do it...

With these steps, we will investigate what happens when we put too much into a single test method:

  1. Create a new file named to put out application code in for this recipe.
  1. Pick a class to test. In this case, we will use an alternative version of the Roman numeral converter, which converts both ways:
class RomanNumeralConverter(object):     def __init__(self): 
        self.digit_map = {"M":1000, "D":500, "C":100, "L":50, "X":10, "V":5, "I":1} 
    def convert_to_decimal(self, roman_numeral): 
        val = 0 
        for char in roman_numeral:         val += self.digit_map[char] 
    return val 
    def convert_to_roman(self, decimal):         val = "" 
    while decimal > 1000:         val += "M" 
        decimal -= 1000     while decimal > 500: 
        val += "D" decimal -= 500 while decimal > 100: ...

Get Python Testing Cookbook. now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.