I have a doctest which expects an IOError when a file is not found.
>>> configParser('conffig.ini') # should not exist
Traceback (most recent call last):
...
IOError: No such file: /homes/ndeklein/workspace/MS/PyMS/conffig.ini
However, if I want to test this from a different pc, or someone else wants to test it, the path isn’t going to be /homes/ndeklein/workspace/MS/PyMS/. I would want to do
>>> configParser('conffig.ini') # should not exist
Traceback (most recent call last):
...
IOError: No such file: os.path.abspath(conffig.ini)
but because it is in the docstring it sees os.path.abspath( as part of the result.
How can I make the result of the docstring test variable?
Do you actually need to match against the pathname? If not then just use ellipsis to skip that part of the output:
If you do then you’ll need to catch the error and test the value by hand. Something like: