New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doctest should support fixtures #49149
Comments
The doctest module should have support for fixtures (e.g. setUp and It is very silly to be forced to always re-import all the modules needed |
I disagree. Purpose of __doc__ is to explain functionality all at once. $ python -c 'from a_module import thing; help(thing)' The doctest module is a lightweight nicety that helps verify that which I'm among the "Choose correct tool for the job. python comes with full |
I concur with David. This is not in the spirit of the doc test module. Tim, I recommend rejecting this request. |
I was proposing to adopt doctest in the biopython project (modules for Doctest is very useful to document modules that will be used by many
|
My goodness, that's the starting base sequence to gene 38c, chromosome 4
def TpedIterator(handle):
Tped_stream = open('cricket.sequence','r')
ti = TpedIterator(Tped_stream)
for marker in ti:
use(marker)
'''
|
For unittests I recommend two things instead of need for doctest change. class Tped_use_cases(...):
def test_Marker_iteration(self):
|
The OP's problem, i.e. the need to reimport modules in every docstring I like the following trick: def getextraglobs():
import StringIO, tempfile, ...
return locals()
doctest.testmod(extraglobs=getextraglobs()) This however does not solve a problem of cleanup after examples and some |
Tim, any opinion on whether this should be kept open or not? |
I stopped understanding doctest the last time it was rewritten - it got far more generalized than I ever intended already. It's up to the younger generation to decide how much more inscrutable to make it now ;-) |
I suggest this is closed as "won't fix" as David and Raymond are against it and Tim says he no longer understands doctest. |
I am closing this for both the general reasons already given and the lack of a proposed api that could programmed, Hence there is no example code that would run and hence no specifics to approve. If someone wanted to pursue this, python-ideas would be a better place. One of the general reasons given is that the example does not demonstrate a real need for the fixtures proposed. My take on the example code is this. The input to TpedIterator is an iterable of lines. A list of lines will work as well an an open file. I would create a file of example lists and import the one needed for each docstring. For the example given. def TpedIterator(lines):
'''Yield Marker for each line of lines. >>> from biopython.sample_data import Tped
>>> for marker in TpedIterator(Tped):
... print(marker)
Marker rs10000543, 2 individuals
Marker rs10000929, 2 individuals
Marker rs10002472, 2 individuals
''' |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: