Chris@87: """ Doctests for NumPy-specific nose/doctest modifications Chris@87: Chris@87: """ Chris@87: from __future__ import division, absolute_import, print_function Chris@87: Chris@87: # try the #random directive on the output line Chris@87: def check_random_directive(): Chris@87: ''' Chris@87: >>> 2+2 Chris@87: #random: may vary on your system Chris@87: ''' Chris@87: Chris@87: # check the implicit "import numpy as np" Chris@87: def check_implicit_np(): Chris@87: ''' Chris@87: >>> np.array([1,2,3]) Chris@87: array([1, 2, 3]) Chris@87: ''' Chris@87: Chris@87: # there's some extraneous whitespace around the correct responses Chris@87: def check_whitespace_enabled(): Chris@87: ''' Chris@87: # whitespace after the 3 Chris@87: >>> 1+2 Chris@87: 3 Chris@87: Chris@87: # whitespace before the 7 Chris@87: >>> 3+4 Chris@87: 7 Chris@87: ''' Chris@87: Chris@87: def check_empty_output(): Chris@87: """ Check that no output does not cause an error. Chris@87: Chris@87: This is related to nose bug 445; the numpy plugin changed the Chris@87: doctest-result-variable default and therefore hit this bug: Chris@87: http://code.google.com/p/python-nose/issues/detail?id=445 Chris@87: Chris@87: >>> a = 10 Chris@87: """ Chris@87: Chris@87: def check_skip(): Chris@87: """ Check skip directive Chris@87: Chris@87: The test below should not run Chris@87: Chris@87: >>> 1/0 #doctest: +SKIP Chris@87: """ Chris@87: Chris@87: Chris@87: if __name__ == '__main__': Chris@87: # Run tests outside numpy test rig Chris@87: import nose Chris@87: from numpy.testing.noseclasses import NumpyDoctest Chris@87: argv = ['', __file__, '--with-numpydoctest'] Chris@87: nose.core.TestProgram(argv=argv, addplugins=[NumpyDoctest()])