[Twisted-Python] Trial Loader: nested test suites

Jonathan Lange jml at mumak.net
Tue Nov 21 14:40:56 MST 2006


On 11/22/06, Markus Schiltknecht <markus at bluegap.ch> wrote:
> Hi,
>
> I've recently been wondering if it's possible to nest test suites with
> trial. I've been experimenting with the Loader and the Runner to achieve
> what I want.
>

You can already nest TestSuites. That's half the point of having them.
For example:
    suite = TestSuite()
    suite.addTest(SomeTestCase('test_foo'))
    suite.addTest(AnotherTestCase('test_baz'))
    outerSuite = TestSuite()
    outerSuite.addTest(suite)
    outerSuite.addTest(SomeTestCase('test_bar))
    assert outerSuite.countTestCases() == 3
    result = TestResult()
    outerSuite.run(result)
    assert result.testsRun == 3

Perhaps you mean something else.

> I came up with the following patch. Does such a thing have any chance of
> being accepted?
>

Before anything gets in to Twisted, it has to have a ticket on the
issue tracker, "decent" code and unit tests.  See
http://twistedmatrix.com/trac/wiki/ReviewProcess and
http://twistedmatrix.com/projects/core/documentation/howto/policy/coding-standard.html
for more information.

Looking at your patch, you seem to be doing two things: adding setUp
and tearDown all over the place; and fiddling with the loadPackage()
function. A casual scan doesn't tell me if those two changes depend on
each other. Smaller patches are more likely to be accepted.

More importantly than that, I'm still not clear on what problem you
are trying to solve.

Also I should note that I am hesitant to allow Trial's suites to run
any user code apart from unit tests. A lot of bad code has been
written that way.

cheers,
jml




More information about the Twisted-Python mailing list