allowing output of code that is unittested?

Ulrich Eckhardt eckhardt at satorlaser.com
Thu Jul 16 09:56:13 CEST 2009


per wrote:
> i am using the standard unittest module to unit test my code. my code
> contains several print statements which i noticed are repressed when i
> call my unit tests using:
> 
> if __name__ == '__main__':
>     suite = unittest.TestLoader().loadTestsFromTestCase(TestMyCode)
>     unittest.TextTestRunner(verbosity=2).run(suite)

I have here

   if __name__ == '__main__':
       unittest.main()

preceded by classes which derive from unittest.TestCase. Running this allows
me to write to stdout using print as usual, even though it's ugly because
it clutters the output of the testcases.

Uli

-- 
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932




More information about the Python-list mailing list