Skip to content

Commit

Permalink
Merge pull request #39 from perrinjerome/fix/debug-checker
Browse files Browse the repository at this point in the history
doctest: use outputchecker argument also in debug mode.
  • Loading branch information
benji-york authored Nov 5, 2023
2 parents b3c9f18 + ae5d901 commit 49344f4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/manuel/bugs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,34 @@ instead:
<memory>


OutputChecker and debug
-----------------------

When running in debug mode, such as when using the ``-D`` option of
``zope.testrunner``, the ``outputchecker`` of ``manuel.doctest.Manuel``
was ignored.

.. code-block:: python
import doctest
import os.path
import manuel.doctest
import manuel.testing
doc = os.path.join(__file__, '..', 'doc3.ex')

checked_outputs = []
class CustomChecker(doctest.OutputChecker):
def check_output(self, want, got, optionflags):
checked_outputs.append((want, got))
return True


m = manuel.doctest.Manuel(checker=CustomChecker())
>>> suite = manuel.testing.TestSuite(m, doc)
>>> suite.debug()
>>> checked_outputs
[('2\n', '1\n')]


DocTestRunner peaks at sys.argv
-------------------------------

Expand Down
4 changes: 3 additions & 1 deletion src/manuel/doctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def __init__(self, optionflags=0, checker=None, parser=None):
self.runner = DocTestRunner(
optionflags=optionflags, checker=checker, verbose=False
)
self.debug_runner = DebugRunner(optionflags=optionflags, verbose=False)
self.debug_runner = DebugRunner(
optionflags=optionflags, checker=checker, verbose=False
)

def evaluate_closure(region, document, globs):
# capture "self"
Expand Down

0 comments on commit 49344f4

Please sign in to comment.