[SciPy-dev] Using doctest

David M. Cooke cookedm at physics.mcmaster.ca
Sat Oct 29 18:52:53 EDT 2005


I've added some tests for scipy.base.polynomial and  
scipy.base.ufunclike, but I used doctests instead of writing out  
something with unittest. They're run by using a test_suite(level)  
function in the appropriate test module.

They were much easier to write than using the unittest API: copy-and- 
paste from my terminal window, mostly :-)

I'm not familiar with the internals of scipy.test.testing, so I don't  
know if there's something I'm missing when setting them up. It does  
require Python 2.3 or higher to make a unittest test suite from the  
doctest, though.

On another note: the shadowing of the scipy.test package by the  
scipy.test function can be annoying, especially if someone wants to  
reuse it. All usages of scipy.test.testing in scipy right now are of  
the form "from scipy.test.testing import *". But because of the test 
() function, you can't do "import scipy.test.testing as T" for  
instance, which is just plain confusing, and difficult for us in the  
"no-import-*" camp :-). Now, you can do "from scipy.test import  
testing as T", but that's not obvious.

Personally, I'd suggest renaming the test() function to runtests(),  
but I can see how this is a problem considering the documentation,  
etc., about test.

-- 
|>|\/|<
/------------------------------------------------------------------\
|David M. Cooke              http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca




More information about the SciPy-Dev mailing list