How many times does unittest run each test?

Roy Smith roy at panix.com
Sat Aug 10 19:14:09 EDT 2013


On Saturday, August 10, 2013 1:40:43 PM UTC-7, Roy Smith wrote:
> > For example, you drag in the logging module, and do some semi-complex 
> > configuration.  Are you SURE your tests are getting run multiple times, 
> > or maybe it's just that they're getting LOGGED multiple times.  Tear out 
> > all the logging stuff.  Just use a plain print statement.

In article <35d12db6-c367-4a45-a68e-8ed4c0ae1ee7 at googlegroups.com>,
 Josh English <Joshua.R.English at gmail.com> wrote:

> Ok, then why would things get logged multiple times?

Maybe you've got two different handlers which are both getting the same 
logging events and somehow they both end up in your stderr stream.  
Likely?  Maybe not, but if you don't have any logging code in the test 
at all, it becomes impossible.  You can't have a bug in a line of code 
that doesn't exist (yeah, I know, that's a bit of a handwave).

When a test (or any other code) is doing something you don't understand, 
the best way to start understanding it is to create a minimal test case; 
the absolute smallest amount of code that demonstrates the problem.

I don't understand the whole SimpleChecker class.  You've created a 
class, and defined your own __call__(), just so you can check if a 
string is in a list?  Couldn't this be done much simpler with a plain 
old function:

def checker(thing):
    print "calling %s" % thing
    return thing in ['a','b','c']



More information about the Python-list mailing list