workaround odd nose problem causing the run_tests function to be called even if the file is not main - refs #1539
This commit is contained in:
parent
1c9aa5bc09
commit
3980eea30a
1 changed files with 18 additions and 17 deletions
|
@ -58,24 +58,25 @@ def get_unique_colors(im):
|
|||
pixels = sorted(pixels)
|
||||
return map(pixel2rgba,pixels)
|
||||
|
||||
def run_tests(iterable):
|
||||
def run_tests(iterable=None):
|
||||
failed = 0
|
||||
for test in iterable:
|
||||
try:
|
||||
test()
|
||||
sys.stderr.write("\x1b[32m✓ \x1b[m" + test.__name__ + "\x1b[m\n")
|
||||
except:
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
failed += 1
|
||||
sys.stderr.write("\x1b[31m✘ \x1b[m" + test.__name__ + "\x1b[m\n")
|
||||
for mline in traceback.format_exception_only(exc_type, exc_value):
|
||||
for line in mline.rstrip().split("\n"):
|
||||
sys.stderr.write(" \x1b[31m" + line + "\x1b[m\n")
|
||||
sys.stderr.write(" Traceback:\n")
|
||||
for mline in traceback.format_tb(exc_tb):
|
||||
for line in mline.rstrip().split("\n"):
|
||||
sys.stderr.write(" " + line + "\n")
|
||||
sys.stderr.flush()
|
||||
if iterable:
|
||||
for test in iterable:
|
||||
try:
|
||||
test()
|
||||
sys.stderr.write("\x1b[32m✓ \x1b[m" + test.__name__ + "\x1b[m\n")
|
||||
except:
|
||||
exc_type, exc_value, exc_tb = sys.exc_info()
|
||||
failed += 1
|
||||
sys.stderr.write("\x1b[31m✘ \x1b[m" + test.__name__ + "\x1b[m\n")
|
||||
for mline in traceback.format_exception_only(exc_type, exc_value):
|
||||
for line in mline.rstrip().split("\n"):
|
||||
sys.stderr.write(" \x1b[31m" + line + "\x1b[m\n")
|
||||
sys.stderr.write(" Traceback:\n")
|
||||
for mline in traceback.format_tb(exc_tb):
|
||||
for line in mline.rstrip().split("\n"):
|
||||
sys.stderr.write(" " + line + "\n")
|
||||
sys.stderr.flush()
|
||||
return failed
|
||||
|
||||
def side_by_side_image(left_im, right_im):
|
||||
|
|
Loading…
Reference in a new issue