def test_range(self):
     "Does draw raise a ValueError an argument is a non-positive integer?"
     n = 4   #number of arguments of graphpaper.draw
     for i in range(n):
         with self.assertRaises(ValueError):
             args = n * [1]   #a list of n copies of 1
             args[i] = 0      #Introduce a bad argument.
             graphpaper.draw(*args)
 def test_type(self):
     "Does draw raise a TypeError if an argument is a non-integer?"
     n = 4   #number of arguments of graphpaper.draw
     badArgs = (None, "", 1.0, (), [], {}, set())    #True and False are ints.
     for i in range(n):
         for badArg in badArgs):
             with self.assertRaises(TypeError):
                 args = n * [1]     #a list of n copies of 1
                 args[i] = badArg   #Introduce a bad argument.
                 graphpaper.draw(*args)
 def test_return(self):
     "Does draw return the correct value?"
     n = 5   #maximum dimension
     for rowsOfBoxes in range(1, n):
         for columnsOfBoxes in range(1, n):
             for rowsOfSpaces in range(1, n):
                 for columnsOfSpaces in range(1, n):
                     top = "+" + columnsOfSpaces * "-"
                     mid = "|" + columnsOfSpaces * " "
                     tops = columnsOfBoxes * top + "\n"
                     mids = columnsOfBoxes * mid + "\n"
                     correct = rowsOfBoxes * (tops + rowsOfSpaces * mids)
                     self.assertEqual(correct, graphpaper.draw(
                         rowsOfBoxes, columnsOfBoxes,
                         rowsOfSpaces, columnsOfSpaces
                     ))