[TIP] Unittesting command line scripts with unittest2?

Michael Foord fuzzyman at voidspace.org.uk
Thu Jul 29 04:13:57 PDT 2010


On 29/07/2010 05:09, Jorge Vargas wrote:
> On Wed, Jul 28, 2010 at 6:31 PM, holger krekel<holger at merlinux.eu>  wrote:
>    
>> On Wed, Jul 28, 2010 at 18:10 -0400, Jorge Vargas wrote:
>>
>> What i usually do is define a main(args=None) function and set
>> args to sys.argv[1:] in case it is None.  This way you can
>> call "main(['status'])" from your tests and don't need to
>> worry about global sys.argv settings during the test.
>>      
> Right, I think I'm going to do that.
>
> Right now I'm having troubles with the stdout replacement, as it's
> swallowing up the coverage report :)
>
> Seems like tearDown is called after the coverage report, because I get
> the dots and the ok/failure message.
>    
Hmmm... the coverage report is generated in the stopTestRun event, which 
is called after all tests have run (including all tearDowns).

Michael

-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.





More information about the testing-in-python mailing list