doctest + swig example

Leo leo.uaz at gmail.com
Wed Jul 26 16:29:30 EDT 2006


Could someone please spare a .i file with an example doctest that
works? I tried as follows and it fails:

1) I have an osi.i file that generates osi.py and _osi.so. At the very
end I added:
...
%pythoncode %{
def _test():
    import doctest
    doctest.testfile('testOsi.txt')

if __name__ == "__main__":
    _test()
%}
-----------------------

2) I have a testOsi.txt file, whose contents are taken from the output
that works on the terminal, plus some docstring stuff:
...
>>> import osi
>>> cbc = osi.OsiCbcSolverInterface()
>>> cbc.readMps('stein15.mps') # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
Coin0001I At line 15 NAME          STEIN15 ...
Coin0008I STEIN15 read with 0 errors
0
...
------------------------

but the result I get is:
**********************************************************************
File "testOsi.txt", line 15, in testOsi.txt
Failed example:
    cbc.readMps('stein15.mps') # doctest: +ELLIPSIS,
+NORMALIZE_WHITESPACE
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.4/doctest.py", line 1243, in __run
        compileflags, 1) in test.globs
      File "<doctest testOsi.txt[2]>", line 1, in ?
        cbc.readMps('stein15.mps') # doctest: +ELLIPSIS,
+NORMALIZE_WHITESPACE
      File "/home/leolopes/research/poams/code/swimpy/osi.py", line
144, in readMps
        def readMps(*args): return
_osi.OsiCbcSolverInterface_readMps(*args)
    NotImplementedError: No matching function for overloaded
'OsiCbcSolverInterface_readMps'
**********************************************************************

Thanks!
Leo.




More information about the Python-list mailing list