Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Is there a way to run doctests and continue on failure? #3149
Say you have a file named t.py:
""" >>> print(1) >>> print(1) >>> print(1) """ if __name__ == "__main__": import doctest doctest.testmod()
When I run this, I would get:
However, when I run with pytest, I would only get the first failure:
I've tried to dig through all the options form the documentation but I wan't able to figure it out. Is there a way to have pytest report all the failures at once? Otherwise I'd have to fix the failures one by one, which gets tedious. I tried to put in various entries in --doctest-report='none' but can't get it to work.
Here is the relevant section in setup.cfg:
Here is my pip list:
I ran a debugger in the two cases and it seems like in _pytest/doctest.py it would uses doctest.DebugRunner instead of the testmod() case which uses the doctest.DocTestRunner. The DebugRunner would raise an exception when it calls the self.report_failure(). In such case it would not continue to run the rest of the examples. The DocTestRunner would output the Expected/Got failure but would not raise an exception.
I'm not so familiar with the _pytest/doctest.py module, but do you know why it would use a DebugRunner there?
It seems like the
I'm not sure how to make it work properly. Should the
@will133 sorry for the delay.
Your proposal of using a custom subclass of
Would you like to give this a try?