[Twisted-Python] Trial Loader: nested test suites
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. I came up with the following patch. Does such a thing have any chance of being accepted? Regards Markus
On 11/22/06, Markus Schiltknecht <markus@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-sta... 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
Hi, Jonathan Lange wrote:
You can already nest TestSuites. That's half the point of having them. <snipped the fine code example> Perhaps you mean something else.
Yes, I want to setUp and tearDown processes and/or network connections in nested testsuites. What's the point in nesting TestSuites if they don't do anything?
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-sta...
Thanks for the hints. I mainly wanted to make sure it's worth following that path further, which I'm still very uncertain.
Looking at your patch, you seem to be doing two things: adding setUp and tearDown all over the place;
Wait, that's a little exaggerated. Two places: before and after running a testsuite and when loading it. You can't possibly insert it at less places if you want that functionality.
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.
The fiddling in loadPackage makes sure it checks every module for setUp and tearDown methods by really recursively call loadByName() for every sub-module (even if it does not contain test cases).
More importantly than that, I'm still not clear on what problem you are trying to solve.
Please have a look at the thread in [1], that message explains best, what I want to achieve.
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.
That's what I fear will break the neck of integrating this. I know I'm not writing standard unit tests, but something similar. Now, I know unit tests should be simple and testing only one unit of code. But what if you *want* to test your complete program, simulate network outages and the like. What's so entirely different to unit testing, besides needing little improvements? Regards Markus [1]: http://twistedmatrix.com/pipermail/twisted-python/2006-November/014370.html
participants (2)
-
Jonathan Lange
-
Markus Schiltknecht