Re: unit test for a printing method

2006-08-29 Thread Marco Wahl
"Fredrik Lundh" <[EMAIL PROTECTED]> writes: >>> >>> 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. > > http://docs.python.org/lib/doctest-unittest-api.html Ahh, that's good to know that doctests can be

Re: unit test for a printing method

2006-08-29 Thread Fredrik Lundh
"noro" wrote: >> why are you trying to reinvent doctest ? > > it was my understanding that "doctest" is intented to test the little > examples in a function/class documention, do people use it for more > then that, i.e - do an extentive output testing for thier apps? yes (by using doctest to test

Re: unit test for a printing method

2006-08-29 Thread noro
Fredrik Lundh wrote: > 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 ? > >

Re: unit test for a printing method

2006-08-29 Thread Fredrik Lundh
Marco Wahl wrote: > Fredrik Lundh <[EMAIL PROTECTED]> 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 ... >>

Re: unit test for a printing method

2006-08-28 Thread Marco Wahl
> [OP] What is the proper way to test (using unit test) a method that print > information? > [...] Fredrik Lundh <[EMAIL PROTECTED]> writes: > > Scott David Daniels wrote: > >> For silly module myprog.py: >> def A(s): >> print '---'+s+'---' >> in test_myprog.py: >> import unitte

Re: unit test for a printing method

2006-08-28 Thread Gabriel Genellina
At Monday 28/8/2006 12:59, Fredrik Lundh wrote: > What is the proper way to test (using unit test) a method that print > information? > for example: > > def A(s): > print '---'+s+'---' > > and i want to check that A("bla") really print out "---bla---" http://docs.python.org/lib/module-

Re: unit test for a printing method

2006-08-28 Thread Fredrik Lundh
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 ? -- http://mail.python.org/mailman/listin

Re: unit test for a printing method

2006-08-28 Thread Scott David Daniels
noro wrote: > What is the proper way to test (using unit test) a method that print > information? > for example: > > def A(s): > print '---'+s+'---' > > and i want to check that A("bla") really print out "---bla---" > > thanks > amit > For silly module myprog.py: def A(s):

Re: unit test for a printing method

2006-08-28 Thread Diez B. Roggisch
noro wrote: > What is the proper way to test (using unit test) a method that print > information? > for example: > > def A(s): > print '---'+s+'---' > > and i want to check that A("bla") really print out "---bla---" You can replace sys.stdout with a cStringIO-object or any other file-p

Re: unit test for a printing method

2006-08-28 Thread Fredrik Lundh
noro wrote: > What is the proper way to test (using unit test) a method that print > information? > for example: > > def A(s): > print '---'+s+'---' > > and i want to check that A("bla") really print out "---bla---" http://docs.python.org/lib/module-doctest.html -- http://mail.pyth

unit test for a printing method

2006-08-28 Thread noro
What is the proper way to test (using unit test) a method that print information? for example: def A(s): print '---'+s+'---' and i want to check that A("bla") really print out "---bla---" thanks amit -- http://mail.python.org/mailman/listinfo/python-list