[mnet-devel] patch: use twisted.trial for unit tests

Brian Warner warner at lothar.com
Mon Apr 19 05:32:50 BST 2004


> after merging this, i tried to run:
>  python setup.py test -s mnetlib/test/test_localblockstore.py

>   File "setup.py", line 479, in run
>     runner = unittest.TextTestRunner(verbosity=self.verbosity)
> AttributeError: 'module' object has no attribute 'TextTestRunner'

The problem is that trial's "unittest" module is not a drop-in replacement
for the standard library's module, at least from the invocation side. Trial
is typically invoked from the command line, rather than programmatically. The
above test would be run with a command like so:

 PYTHONPATH=. trial mnetlib/test/test_localblockstore.py

I'll ask around to see if there is a sensible way to run trial from within a
setup.py command.. it will depend upon which interfaces are meant to be
exposed. Worst case we'll just have to build up a fake argv[] array and have
trial parse it instead of sys.argv .

For the curious, bin/trial just imports twisted.scripts.trial and then calls
the run() method. There is another entry point called reallyRun(config) which
takes a dictionary-like object of options, this could be used to construct an
appropriate list of tests to be executed. Note that trial handles the
importing and globbing, so it shouldn't be necessary to perform these tasks
in setup.py itself.

cheers,
 -Brian



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
mnet-devel mailing list
mnet-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mnet-devel




More information about the Mnet-devel mailing list