allowing output of code that is unittested?

P

per

hi all,

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)

is there a way to allow all the print statements in the code that is
being run by the unit test functions to be printed to stdio? i want
to be able to see the output of the tested code, in addition to the
output of the unit testing framework.

thank you.
 
D

Diez B. Roggisch

per said:
hi all,

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)

is there a way to allow all the print statements in the code that is
being run by the unit test functions to be printed to stdio? i want
to be able to see the output of the tested code, in addition to the
output of the unit testing framework.


I use nosetests to discover & run tests, and that has an "-s"-option
that does exactly that.

Diez
 
U

Ulrich Eckhardt

per said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top