Re: [Pyunit-interest] How do you import a module with unit tests and then run them?
Brought to you by:
purcell
From: Michal W. <sa...@ma...> - 2002-08-01 00:52:34
|
On Wed, 31 Jul 2002, Andrew P. Lentvorski wrote: > So, how do I get test_unittest2.py to call the tests in test_unittest.py > and run them correctly? I am open to changing the original test code, > explicitly assigning stuff, etc. to make this work. I would even use > execfile or the imp module if required. > > Lest someone think that this is just a really stupid thing to do, I will > point out that the same issues arise if you try to use the python debugger > on a unittest as it also wants to import the module and then run the unit > tests. Hey Andrew, well, the defaultTest thing seems to be looking in the top level namespace, so if you put... import test_unittest from test_unittest import * ... at the top of test_unittest2 , it'll work fine. A better idea might be to use a different unittest funciton - one that takes an explicit test suite. --- Personally, when I want to debug a test case, I just add this line to the place in the test where I want to start debugging: import pdb; pdb.set_trace() Then I just run my tests as usual. ('Course I work with the TextTestRunner... I don't know how useful that is in the GUI) Cheers, - Michal http://www.sabren.net/ sa...@ma... ------------------------------------------------------------ Switch to Cornerhost! http://www.cornerhost.com/ High Powered Hosting - With a Human Touch. :) ------------------------------------------------------------ |