Running one single test...

Andrew Bennetts andrew-pythonlist at puzzling.org
Fri Aug 22 01:08:23 EDT 2003


On Thu, Aug 21, 2003 at 09:16:08PM -0700, Timothy Grant wrote:
> At work we use Perl and a home rolled unittesting mechanism. One of the things 
> I love about That testing mechanism is that I can run one single test. In 
> fact, I've configured Vim to run the current test and either tell me if it 
> passes or tell me the error when it doesn't.
> 
> I'd love to do something similar with PyUnit, but I have yet to figure out how 
> to run one single test.
> 
> Any help would be greatly appreciated.

Twisted has a PyUnit-compatible unit testing tool called trial that can do
this; it has a command-line utility that allows you do all of these:

    $ trial twisted.test
    $ trial twisted.test.test_imap  # ("trial twisted/test/test_imap.py"
                                    #  works too)
    $ trial twisted.test.test_imap.IMAP4ServerTestCase
    $ trial twisted.test.test_imap.IMAP4ServerTestCase.testLogout

(i.e. run a package of modules with testcases, or run a module of testcases,
or run a single testcase, or run a single test in a test case).

-Andrew.






More information about the Python-list mailing list