Forum Archive

Putting doctests into a separate file?

ccc

I have been playing with doctests and they are really cool/helpful but they can get a bit verbose. I remember reading somewhere that Pythonista supports putting your doctests in a separate file but I can not remember how that was supposed to work? Can someone provide me some tips/tricks?

omz

It's only supported in the beta(s). There's a doctest (markdown) template in the "new file" dialog.

JonB

or just name your file with .doctest

ccc

If my collaborator is using the App Store version of Pythonista, is it possible for them to run the doctests?

omz

@ccc The collaborator could just put a simple script like this in the editor actions (wrench) menu:

import doctest, editor
doctest.testfile(editor.get_path(), module_relative=False)