fixup utility to single test file but all tests within - refs #1539

This commit is contained in:
Dane Springmeyer 2013-01-18 13:13:01 -08:00
parent 1c42f48613
commit 8b18f9f5d4
3 changed files with 22 additions and 23 deletions

View file

@ -2,7 +2,7 @@
from nose.tools import *
import os,sys
from utilities import execution_path, run_tests, Todo
from utilities import execution_path, run_all, Todo
from utilities import get_unique_colors, pixel2channels, side_by_side_image
import mapnik
@ -254,9 +254,9 @@ def test_background_image_with_alpha_and_background_color_against_composited_con
im1.demultiply()
# compare image rendered (compositing in `agg_renderer<T>::setup`)
# vs image composited via python bindings
raise Todo("looks like we need to investigate PNG rounding when saving")
raise Todo("looks like we need to investigate PNG color rounding when saving")
eq_(get_unique_colors(im),get_unique_colors(im1))
if __name__ == "__main__":
setup()
run_tests(eval(x) for x in dir() if x.startswith("test_"))
run_all(eval(x) for x in dir() if x.startswith("test_"))

View file

@ -1,7 +1,7 @@
#!/usr/bin/env python
from nose.tools import *
from utilities import execution_path, run_tests
from utilities import execution_path, run_all
from utilities import side_by_side_image
import os, mapnik
import re
@ -65,4 +65,4 @@ if 'shape' in mapnik.DatasourceCache.plugin_names():
if __name__ == "__main__":
setup()
run_tests(eval(x) for x in dir() if x.startswith("test_"))
run_all(eval(x) for x in dir() if x.startswith("test_"))

View file

@ -58,25 +58,24 @@ def get_unique_colors(im):
pixels = sorted(pixels)
return map(pixel2rgba,pixels)
def run_tests(iterable=None):
def run_all(iterable):
failed = 0
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()
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):