...

/

More Halting, More Fire

More Halting, More Fire

We'll cover the following...

Along with testing numbers that are too large, you need to test numbers that are too small. As we noted in our functional requirements, Roman numerals cannot express 0 or negative numbers.

Press + to interact
import roman2
print (roman2.to_roman(0))
#''
print (roman2.to_roman(-1))
#''

Well that’s not good. Let’s add tests for each of these conditions.

Press + to interact
import unittest
class ToRomanBadInput(unittest.TestCase):
def test_too_large(self):
'''to_roman should fail with large input'''
self.assertRaises(roman3.OutOfRangeError, roman3.to_roman, 4000) #①
def test_zero(self):
'''to_roman should fail with 0 input'''
self.assertRaises(roman3.OutOfRangeError, roman3.to_roman, 0) #②
def test_negative(self):
'''to_roman should fail with negative input'''
self.assertRaises(roman3.OutOfRangeError, roman3.to_roman, -1) #③

① The test_too_large() ...