I am having trouble and difficulties with Pilgrim's Dive into python 3 Unit Testing chapter. I've run the exact same code in romantest2.py. Exceptions are not being handled in the code provided on the examples. I have deduced the example on the book into a smaller snippet:
TestCase1.py
import unittest class ToRomanBadInput(unittest.TestCase): def test_too_large(self): '''to_roman should fail with large input''' self.assertRaises(roman2.OutOfRangeError,roman2.to_roman,4000) if __name__ == '__main__': unittest.main() the file roman2.py
class OutOfRangeError(ValueError): pass def to_roman(n): raise OutOfRangeError("Value n {0} is larger than 3999.".format(n)) I can't seem to move on this part. What happen is that I expect the test case to fail. But it didn't instead it shows:
.. ------------------------------------------------------------ Ran 2 tests in 0.000s OK I am using and running this code PyDev in Eclipse and the version of python is version 3.3.3