This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Return results from doctest.run_docstring_examples()
Type: enhancement Stage: patch review
Components: Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: giampaolo.rodola, rbcollins, tim.peters, zach.ware
Priority: normal Keywords: patch

Created on 2014-04-01 18:12 by giampaolo.rodola, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
doctest.patch giampaolo.rodola, 2014-04-01 18:12 review
Messages (3)
msg215335 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2014-04-01 18:12
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.
msg247729 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2015-07-31 03:22
Patch looks straightforward enough to me, and I think it's a good idea; tests would be nice though (was another issue opened for that?).
msg248476 - (view) Author: Robert Collins (rbcollins) * (Python committer) Date: 2015-08-12 21:36
So, I think this needs a test; returning a generator would be nice but would be an API break.

Also the doc update needs to say 3.6 now.

Thanks; moving back to patch review.
History
Date User Action Args
2022-04-11 14:58:01adminsetgithub: 65325
2015-08-12 21:36:09rbcollinssetnosy: + rbcollins

messages: + msg248476
stage: commit review -> patch review
2015-07-31 03:22:30zach.waresetversions: + Python 3.6, - Python 3.5
type: enhancement

nosy: + zach.ware
title: Integrate doctest.run_docstring_examples() with unittest -> Return results from doctest.run_docstring_examples()
messages: + msg247729
stage: commit review
2014-04-01 18:12:24giampaolo.rodolacreate