[Twisted-Python] Some way for Trial to allow selective running of tests?

Tim Allen tim at commsecure.com.au
Thu Aug 27 20:32:21 EDT 2009

Don Dwiggins <ddwiggins at advpubtech.com> wrote:
> Phil Christensen wrote:
> > trial takes an argument at the command-line where you can specify a  
> > package or test case.
> > 
> > for example:
> > 
> > 	trial twisted
> > 	trial twisted.test
> > 	trial twisted.test.test_explorer
> > 	trial twisted.test.test_explorer.TestBrowser
> > 	trial twisted.test.test_explorer.TestBrowser.test_chain
> > 
> > lets you get more and more specific.
> > 
> > -phil
> Sorry, I'm feeling dense.  I currently run it as
> "trial MyServerTestFile.py"; it's not a package or part of one.  In the 
> file are several classes, each with several test cases.  How would I 
> adapt the above to my needs?

trial takes either a path and filename, or a Python import name (I'm
not sure what the exact term here is).

If you ran python in the same directory where you ran "trial" in your
example, you could say:

    import MyServerTestFile

...to refer to a particular test method, and trial will accept the same

    trial MyServerTestFile.MyServerTestCase.test_my_server

In general though, a lot of distribution and packaging and deployment
things become easier if your project is laid out in Python packages. I
usually follow these rules and everything turns out pretty well:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20090828/4ce7e306/attachment.pgp 

More information about the Twisted-Python mailing list