Skip to content

Conversation

@donbarbos
Copy link
Contributor

@donbarbosdonbarbos commented Mar 12, 2025

we can use next command for doctests: ./python -m doctest Lib/heapq.py -v

and we already loading doctest in next line:

defload_tests(loader, tests, ignore):
# The 'merge' function has examples in its docstring which we should test
# with 'doctest'.
#
# However, doctest can't easily find all docstrings in the module (loading
# it through import_fresh_module seems to confuse it), so we specifically
# create a finder which returns the doctests from the merge method.
classHeapqMergeDocTestFinder:
deffind(self, *args, **kwargs):
dtf=doctest.DocTestFinder()
returndtf.find(py_heapq.merge)
tests.addTests(doctest.DocTestSuite(py_heapq,
test_finder=HeapqMergeDocTestFinder()))
returntests

@donbarbos
Copy link
ContributorAuthor

cc @vstinner

Copy link
Member

@vstinnervstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rhettinger
Copy link
Contributor

I don't think this addresses any known or real user problem. It just makes life more difficult for the module maintainer.

@donbarbos
Copy link
ContributorAuthor

I don't think this addresses any known or real user problem. It just makes life more difficult for the module maintainer.

This looks like redundant code. And we already have more general way to run doctest (via python -m doctest)

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@donbarbos@rhettinger@vstinner