I defined the SpamException class in the spam module. Now I want to test the spam_function function that raises this exception. Therefore, I wrote the following doctrine.
>>> spam_function() Traceback (most recent call last): .... SpamException
The test succeeds in Python 2.x, but in Python 3.x the test failed. The following test runs on Python 3.x.
>>> spam_function() Traceback (most recent call last): .... spam.SpamException
A notable difference here is the inclusion of the module name in the exception name. So, how can I write a doctest that works on both Python 2.x and 3.x?
source share