[Pyunit-interest] Re: Information about library unittest.py
Brought to you by:
purcell
From: Steve P. <ste...@ya...> - 2003-12-13 11:56:43
|
Hi Remi, On Wednesday 10 December 2003 09:48, you wrote: > I would like to write in a log file the traces of the unittest library > stream output. But I don't want to modify your library, so is there a > simple solution to write it ? How about this: import unittest class MyTestCase(unittest.TestCase): def test_something(self): pass tests = unittest.defaultTestLoader.loadTestsFromTestCase(MyTestCase) output = open('/tmp/output-file.txt', 'w') unittest.TextTestRunner(output).run(tests) output.close() You can use other methods of unitttest.defaultTestLoader to load tests in different ways, e.g. 'loadTestsFromModule()' or 'loadTestsFromName()'. Best wishes, -Steve (P.S. I'm cc-ing this reply to the pyunit mailing list in case this is of interest to anyone else.) -- Steve Purcell http://advogato.org/person/purcell |