[Twisted-Python] Running Twisted tests with testtools

Jonathan Lange jml at mumak.net
Fri Feb 10 06:32:17 EST 2012


On Fri, Feb 10, 2012 at 11:21 AM, Free Ekanayaka <free at 64studio.com> wrote:
> |--==> On Fri, 10 Feb 2012 09:50:10 +0000, Jonathan Lange <jml at mumak.net> said:
>
>  JL> On Fri, Feb 10, 2012 at 8:43 AM, Free Ekanayaka <free at 64studio.com> wrote:
>  >>Hi Jonathan,
>  >>
>  >>|--==> On Wed, 8 Feb 2012 22:12:34 +0000, Jonathan Lange <jml at mumak.net> said:
>  >>
>  >> [...]
>  >> >>Would you elaborate on that and explain why you come to prefer it over
>  >> >>trial for your new projects?
>  >>
>  >> JL> That's mostly documented here:
>  >>
>  >> JL>   http://testtools.readthedocs.org/en/latest/overview.html
>  >>
>  >> JL> and in the other docs. In a nutshell: details, fixtures, matchers, and
>  >> JL> a bunch of unittest extensions that make it much more flexible, making
>  >> JL> it easy to write things like parallel test runners
>  >>
>  >>Yeah, I like these features a lot too, but leaving out AsynchronousDeferredRunTest
>  >>maybe one could use all these features on top of trial's TestCase,
>  >>by using testtool's TestCase as a kind  of mixin. Not sure it'd work in
>  >>practice though.
>  >>
>
>  JL> Why would you want to?
>
> Maybe be not really that, but I was mainly wondering, maybe Twisted's
> trial machinery for handling tests returning deferreds could be factored
> in a way that it can be re-used by AsynchronousDeferredRunTest (which
> would just be glue code for integrating with testtool's TestCase). This
> way testtool's twisted support would be based on twisted itself.
>
> Not sure it's worth doing if this generalization/refactoring would lead
> to more complex code, but I thought I'd mention it.
>

testtools/_spinner.py could *probably* be moved into Twisted itself
without too much technical hassle. It would have to be a public API
for testtools to rely on it, but it would also have to be an API that
Twisted strongly warned against using.

Then, probably, Trial & testtools could use that. ADRT relies on the
RunTest layer of indirection that testtools has, and has code that is
genuinely useful to anyone running Twisted tests. Moving that into
Twisted would be trickier, since it would mean either duplicating or
depending on testtools.

jml



More information about the Twisted-Python mailing list