-
Notifications
You must be signed in to change notification settings - Fork 102
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
create (and run) doctests in the docstrings #6
Comments
working on this, but hit a roadblock with an annoying problem caused by, in
From IPython and the test suite, this works no prob:
But from a doctest within
Seems like some sort of name clash within the doctest execution context. The only solution I could come up with is renaming
and the docstrings work. Lame, I know, but it's all I could get to work. |
also, i decided to let the test suite do the checking of actual results. Otherwise, to get the doctests to pass, you need
So it's simply replaced by
and the test suite does the "real" testing of expected output. |
yeah, i think we can also send those flags to doctest.testmod() for the first problem, did you try:
? |
I just tried the Turns out it was nosetests that was causing that import problem. Now that I'm using the standard
Docstring testing at the moment has to be done by running the bedtool module; hopefully sphinx's Also, sending the flags like you suggested to So both problems solved! |
when i run
from the base dir, i see the problem you mention above. |
yeah, prob a good PEP8 move to do this. I'm working on some doctests on the bits of downtime I have today, so I'll work on changing this over in the code and in the tests. Another issue is that I can't find a way to pass doctest optionflags to nosetests. (specifically +NORMALIZE_WHITESPACE). There's a patch floating around to provide --doctest-options, but I don't want to rely on a patched nosetests. Any ideas for this? |
i've just converted the whole set, yeah, now only having problems with flags to nosetests |
SHA: 0de20ba |
Sweet, thanks. Merged it. |
Re: optionflags . . . The reason for wanting to pass +normalize_whitespace to nosetests is so that in the source code, all tabs in expected output can be converted to spaces. I initially wanted to do this to avoid potential ambiguous whitespace issues in the python source. But maybe it's worth putting the tabs back in,
What do you think? |
cool. (fyi, i left all the sphinx stuffs unchanged) |
re whitespace, your call, can also use output spariingly in the doctests and just test for equality:
but yes, getting the tests to run through nose as well would be convenient. |
ok, this should work in the base dir:
i removed lots of output from function and method doctests . . . this means they're not very rigorous at the moment, but i think i'd rather keep the rigorous tests in test1.py anyway. eventually i'll probably add minor equality tests like you suggest. also, i learned about the doctest_global_setup config value for sphinx's doctest plugin, which now lets this run doctest within the docs and then compile 'em all (when run from the docs dir):
|
there are some docstrings in the code already but they arent quite in doctest format.
having them run as part of the test-suite--and the stuff in feature.py would be nice.
The text was updated successfully, but these errors were encountered: