[wingide-users] Doctests in 3.1-b3... confused
René Pijlman
reneOnLists at applinet.nl
Sat Apr 26 13:59:41 MDT 2008
I've been playing with doctests in 3.1-b3 Pro on Windows XP.
The first thing I find non-intuitive is that when I open a Python file
containing doctests, nothing happens. Most options in the debug menu are
grayed out, the "Run Tests" button does nothing. It seems I first have
to do Testing > Add current file. I'd expect doctest support to be
available on the current file by default.
Then when I add my file and do "Run all tests" I run into an exception
in unittest.py. Unittest? It seems obvious my file contains only
doctests. Apparently not. I discovered "Default test framework" in the
project settings, and set it to doctest.
Now testing works and I see a tree structure with the tests in my File.
But when I right-click one of the individual tests ("Example #2") in a
function's docstring, and select "Goto source", the first line of my
file is highlighted instead of the line containing my test. When I click
the parent of this test in the tree (the function containing the test)
and "Goto source", Wing indeed highlights the function definition. If
it's not possible to locate the source line of an individual test in a
doc string, I'd expect Wing to at least go to the function definition,
instead of the first line of the file.
Then when I right-click a function or test in the tree and do "Run
test", that part of the tree in the Testing pane simply disappears after
seeing the jogging man for 1 or 2 seconds or so. When I do "Run all
tests" the tree seems to be rebuilt.
When I double-click a failed test, nothing happens. It doesn't expand
and I don't see the output of the test anywhere ("expected ... got ...").
Right-click on a test case and 'Debug test' just prints
"<test-results></test-results>" in the Debug I/O tool.
Running all tests takes about 2 seconds, while they're very trivial (see
source code below).
Perhaps I misunderstand how this is supposed to work, but right now
simply executing my file and looking at the debug output seems a lot
easier than using the testing tool.
This is the source code I used. It contains three trivial failing doctests.
#!/usr/bin/python
def foo():
''' Play with tests in Wing 3.1
This statement prints 'foo'
>>> print 'Foo'
'foo'
This statement prints 'bar'
>>> print 'Bar'
'bar'
'''
pass
# Ad hoc doctests
__test__ = {}
__test__['aTest'] = '''
>>> print 1 + 2
4
'''
def _test():
import doctest
doctest.testmod()
if __name__ == "__main__":
_test()
--
René
More information about the wingide-users
mailing list