Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Alan Gauld
> Suppose I had a function like the following: # def y_n(prompt="Answer yes or no"): while True: answer = raw_input(prompt) if answer in ['y', 'Y', 'yes']: print "You said yes!" break elif answer in ['n', 'N', 'no']: print

Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Danny Yoo
On Tue, 18 Apr 2006, Andre Roberge wrote: > Suppose I had a function like the following: > > def y_n(prompt="Answer yes or no"): >while True: >answer = raw_input(prompt) >if answer in ['y', 'Y', 'yes']: >print "You said yes!" >break >elif answe

Re: [Tutor] unit testing raw_input()

2006-04-18 Thread Michael
On Tuesday 18 April 2006 23:34, Andre Roberge wrote: > Hi all- > > Suppose I had a function like the following: > > [ function that interacts with the outside world ] ... > How could I go about to write an automated test for it? You create a mock for raw_input, put the above code inside a module a

[Tutor] unit testing raw_input()

2006-04-18 Thread Andre Roberge
Hi all- Suppose I had a function like the following: def y_n(prompt="Answer yes or no"): while True: answer = raw_input(prompt) if answer in ['y', 'Y', 'yes']: print "You said yes!" break elif answer in ['n', 'N', 'no']: print "You s