[Twisted-Python] Thoughts about testing

Jonathan Lange jml at mumak.net
Wed Oct 26 18:38:01 MDT 2005


On 26/10/05, David Ripton <dripton at ripton.net> wrote:
> On 2005.10.25 12:59:24 -0400, Jean-Paul Calderone wrote:
> > Rather than hearing about the plethora of new testing libraries
> > appearing, I'd like to hear about features they provide that are
> > valuable for writing tests.  I would certainly like to borrow
> > py.test's magical assert.  What other features are test authors
> > finding useful in some of these projects?
>
> Things I particularly like about py.test, vs. unittest:
>
> 1. assert, not self.failUnlessAllThisUglyCamelCaseActuallyKillsMe()

class FooTest(unittest.TestCase):
    failureException = AssertionError

    def test_foo(self):
        assert False  #yay fails


> 2. You can use module-level test functions.  No need to make a test
> class unless it's actually helpful.  (Yay Java.)

This feature is present in unittest, and presumably works for free in
Trial.  Don't know about cmd line support.

> 3. Tests execute in predictable order.

Trial *ought* to execute tests in a predictable order.  If it doesn't,
please file a bug on http://www.twistedmatrix.com/bugs/, assign it to
'jml' with topic 'trial'.  (Also, please include repro)

> 4. setup_module / setup_class / setup_method.  Handy for reusing
> database connections.

We are working on something better than that.

> 5. A separate test runner binary, so you don't need __main__ boilerplate
> in every test module, and you can put tests in the same module as a
> script (if you don't care about them being found automatically).

*blink*

Thanks for the feedback!
jml




More information about the Twisted-Python mailing list