Re: [Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 23:47, boB Stepp wrote: > adequately testing it. I cannot even conceive of what might be edge > cases for this function. I meant to add, the obvious boundaries for this actual function are passing in non-callable values, or callables that require arguments. And to handle those you

Re: [Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread boB Stepp
On Sun, Oct 2, 2016 at 6:00 PM, Steven D'Aprano wrote: > On Sun, Oct 02, 2016 at 05:47:51PM -0500, boB Stepp wrote: >> In exercise 3.2 of Downey's "Think Python 2" he has a function: >> >> def do_twice(f): >> f() >> f() >> >> As you know, I am trying to learn testing/TDD while doing these

Re: [Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 23:47, boB Stepp wrote: > In exercise 3.2 of Downey's "Think Python 2" he has a function: > > def do_twice(f): > f() > f() > > As you know, I am trying to learn testing/TDD while doing these > exercises. How do I test such a *general* function? You are testing do_twice() no

Re: [Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread Steven D'Aprano
On Sun, Oct 02, 2016 at 05:47:51PM -0500, boB Stepp wrote: > In exercise 3.2 of Downey's "Think Python 2" he has a function: > > def do_twice(f): > f() > f() > > As you know, I am trying to learn testing/TDD while doing these > exercises. How do I test such a *general* function? Should

[Tutor] How to test a function which runs a passed in function twice?

2016-10-02 Thread boB Stepp
In exercise 3.2 of Downey's "Think Python 2" he has a function: def do_twice(f): f() f() As you know, I am trying to learn testing/TDD while doing these exercises. How do I test such a *general* function? Should I create a variety of arbitrary functions in my test file, call the do_twic

Re: [Tutor] Tutor Digest, Vol 152, Issue 3

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 03:50, anish singh wrote: >> Possibly, but we can't tell because >> a) You don't show us the code that parses your input Thanks, that helps. > import os, sys, getopt > import re > import glob > > > def get_full_path(path, pattern): > for (dirpath, dirnames, filenames) in os.walk(

Re: [Tutor] Testing print

2016-10-02 Thread Alan Gauld via Tutor
On 02/10/16 02:46, boB Stepp wrote: >> case. If I know that the result is always an int I can >> use the first case if I know its always a tuple I can >> use the second. But not knowing which is just plain >> messy. > > So in which sorts of scenarios would you use argument unpacking? Any time a

Re: [Tutor] Tutor Digest, Vol 152, Issue 3

2016-10-02 Thread anish singh
> On 01/10/16 09:16, anish singh wrote: > > I am trying to implement grep to just increase my knowledge > > about regular expression. > > > > Below is the program usage: > > python test.py -i Documents/linux/linux/ -s '\w+_readalarm*' > > > > However, due to my lack of knowledge about string handli