[TIP] Nose or zope.testing - running DocFileSuite's
Martin Aspeli
optilude at gmx.net
Sun Nov 18 10:17:16 PST 2007
Hi all,
I'm quite convinced this has to do with me being stupid and missing
something obvious, but I just can't get this to work.
I want to run a DocFileSuite (a doctest in a text file) in a simple
package. I'd like to use zope.testing's DocFileSuite and test-runner,
though I'd be happy to use nose or some other reliable test-runner as well.
I've got a setuptools-installed package 'mock.test', which has a
tests.py that contains:
import os
import sys
import unittest
from zope.testing import doctest, testrunner
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('doctest.txt'),
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
The doctest.txt file is in the same package and contains a trivial
failing test.
I can't for the life of me figure out how to run this doctest, though. I
installed nose, but it won't run the doctest (even with
--with-doctests), though it will run basic tests that I define as methods.
I then tried to use zope.testing.testrunner.run. In bin/test.py, I have:
import sys
import zope.testing.testrunner
defaults = [
'--tests-pattern', '^tests$',
]
if __name__ == '__main__':
zope.testing.testrunner.run(defaults)
I have then tried to use various invocations, such as:
$ bin/tests -s mock.tests -t doctest.txt
or various uses of --path or -m, but it's always "ran 0 tests". :-(
Can someone nudge me in the right direction?
Thanks,
Martin
--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book
More information about the testing-in-python
mailing list