unit test for a printing method

Marco Wahl marco.wahl at gmail.com
Tue Aug 29 02:04:08 EDT 2006


> [OP] What is the proper way to test (using unit test) a method that print
> information?
> [...]

Fredrik Lundh <fredrik at pythonware.com> writes:
>
> Scott David Daniels wrote:
>
>> For silly module myprog.py:
>>      def A(s):
>>          print '---'+s+'---'
>> in test_myprog.py:
>>      import unittest
>>      from cStringIO import StringIO  # or  from StringIO ...
>
> why are you trying to reinvent doctest ?

The OP asked for unit test.  This could be read that
the OP wants to use module unittest.




More information about the Python-list mailing list