[Twisted-Python] Trial Test Runner

Jean-Paul Calderone exarkun at divmod.com
Wed Nov 15 12:43:05 EST 2006


On Wed, 15 Nov 2006 18:09:01 +0100, Markus Schiltknecht <markus at bluegap.ch> wrote:
>Hi,
>
>I'm having a hard time writing a test suite using trial. What's the best 
>documentation available? I've the API Reference as well as the sources at 
>hand, but...
>
>For example I've tried this:
>
>#!/usr/bin/python
># -*- test-case-name: eUnit.test.test_sample -*-
>
>from twisted.trial import unittest, runner, reporter
>
>class Test(unittest.TestCase):
>
>         def testSample(self):
>                 print "hallo welt"
>
>
>if __name__ == "__main__":
>         runner.TrialRunner(reporter.TextReporter).run(Test)
>
>It's failing with:
>TypeError: unbound method countTestCases() must be called with Test instance 
>as first argument (got nothing instead)
>
>Some more documentation (an introduction or tutorial or some such) would be 
>very welcome and helpful.

Trial has a command line tool for running suites, "trial".  If that code is
in eUnit/test/test_sample.py, then you can try any of these commands:

    trial eUnit
    trial eUnit.test
    trial eUnit.test.test_sample
    trial eUnit.test.test_sample.Test
    trial eUnit.test.test_sample.test.testSample
    trial /path/to/eUnit/
    trial /path/to/eUnit/test/
    trial /path/to/eUnit/test/test_sample.py

You don't need any of the code in your __main__ section.

Jean-Paul




More information about the Twisted-Python mailing list