1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 |
1403 |
1404 |
1405 |
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
1421 |
1422 |
1423 |
1424 |
1425 |
1426 |
1427 |
1428 |
1429 |
1430 |
1431 |
1432 |
1433 |
1434 |
1435 |
1436 |
1437 |
1438 |
1439 |
1440 |
1441 |
1442 |
1443 |
1444 |
1445 | |
def summarize(self, verbose=None): |
""" |
Print a summary of all the test cases that have been run by |
this DocTestRunner, and return a tuple `(f, t)`, where `f` is |
the total number of failed examples, and `t` is the total |
number of tried examples. |
|
The optional `verbose` argument controls how detailed the |
summary is. If the verbosity is not specified, then the |
DocTestRunner's verbosity is used. |
""" |
if verbose is None: |
verbose = self._verbose |
notests = [] |
passed = [] |
failed = [] |
totalt = totalf = 0 |
for x in self._name2ft.items(): |
name, (f, t) = x |
assert f <= t |
totalt += t |
totalf += f |
if t == 0: |
notests.append(name) |
elif f == 0: |
passed.append( (name, t) ) |
else: |
failed.append(x) |
if verbose: |
if notests: |
print len(notests), "items had no tests:" |
notests.sort() |
for thing in notests: |
print " ", thing |
if passed: |
print len(passed), "items passed all tests:" |
passed.sort() |
for thing, count in passed: |
print " %3d tests in %s" % (count, thing) |
if failed: |
print self.DIVIDER |
print len(failed), "items had failures:" |
failed.sort() |
for thing, (f, t) in failed: |
print " %3d of %3d in %s" % (f, t, thing) |
if verbose: |
print totalt, "tests in", len(self._name2ft), "items." |
print totalt - totalf, "passed and", totalf, "failed." |
if totalf: |
print "***Test Failed***", totalf, "failures." |
elif verbose: |
print "Test passed." |
return totalf, totalt | |