[issue21126] Integrate doctest.run_docstring_examples() with unittest

Giampaolo Rodola' report at bugs.python.org
Tue Apr 1 20:12:24 CEST 2014


New submission from Giampaolo Rodola':

In order to run a certain function via doctest run_docstring_examples() can be used:
http://stackoverflow.com/a/10081450/376587
The function returns None though.
I am in a situation where I want to run a single function's doctest from a unittest and want to "fail" in case the doctest fails.
Patch in attachment makes run_docstring_examples() return a list of TestResults instances so that you can do:

class TestFoo(unittest.TestCase):

    def test_foo(self):
        ret = doctest.run_docstring_examples(somefun, globals())
        self.assertFalse(ret[0].failed)

Patch lacks tests because run_docstring_examples() is currently not tested. I will open a separate ticket for that.

----------
files: doctest.patch
keywords: patch
messages: 215335
nosy: giampaolo.rodola, tim.peters
priority: normal
severity: normal
status: open
title: Integrate doctest.run_docstring_examples() with unittest
versions: Python 3.5
Added file: http://bugs.python.org/file34697/doctest.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21126>
_______________________________________


More information about the Python-bugs-list mailing list