Skip to content

Commit

Permalink
Add makefile for short test command lines (cf #45)
Browse files Browse the repository at this point in the history
Also make test/python_tests/image_encoding_speed_test.py compliant
with nosetest runner.
  • Loading branch information
yohanboniface committed Sep 24, 2015
1 parent 91f8b79 commit 6a5efb7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ mapnik/paths.py
.mason/
mason_packages/
mapnik/plugins
.noseids
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.PHONY: help test test_verbose tdd test_failed

TEST := nosetests --logging-clear-handlers --with-id

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " test to run all the test suite"
@echo " test_verbose to run all the test suite without output capture"
@echo " tdd to run all the test suite, but stop on the first error"
@echo " test_failed to rerun the failed tests from the previous run"

test:
$(TEST) $(filter-out $@,$(MAKECMDGOALS))

test_verbose:
$(TEST) -s $(filter-out $@,$(MAKECMDGOALS))

tdd:
$(TEST) --stop --pdb $(filter-out $@,$(MAKECMDGOALS))

test_failed:
python setup.py nosetests --logging-clear-handlers --with-id -vv --failed $(ARGS)

$(phony %):
@:
19 changes: 6 additions & 13 deletions test/python_tests/image_encoding_speed_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from timeit import Timer, time

import mapnik

from .utilities import execution_path, run_all
from .utilities import execution_path


def setup():
Expand Down Expand Up @@ -60,7 +59,7 @@ def setup():
iterations = 10


def do_encoding():
def test_encoding():

global image

Expand All @@ -85,7 +84,7 @@ def blank():
blank_im = mapnik.Image(512, 512)
for c in combinations:
t = Timer(blank)
run(blank, blank_im, c, t)
yield run, blank, blank_im, c, t

if 'solid' in tiles:
def solid():
Expand All @@ -94,7 +93,7 @@ def solid():
solid_im.fill(mapnik.Color("#f2efe9"))
for c in combinations:
t = Timer(solid)
run(solid, solid_im, c, t)
yield run, solid, solid_im, c, t

if 'many_colors' in tiles:
def many_colors():
Expand All @@ -103,15 +102,15 @@ def many_colors():
many_colors_im = mapnik.Image.open('../data/images/13_4194_2747.png')
for c in combinations:
t = Timer(many_colors)
run(many_colors, many_colors_im, c, t)
yield run, many_colors, many_colors_im, c, t

if 'aerial_24' in tiles:
def aerial_24():
return eval('image.tostring("%s")' % c)
aerial_24_im = mapnik.Image.open('../data/images/12_654_1580.png')
for c in combinations:
t = Timer(aerial_24)
run(aerial_24, aerial_24_im, c, t)
yield run, aerial_24, aerial_24_im, c, t

for key, value in sorted(sortable.items(), key=lambda i: (i[1], i[0])):
s = results[key]
Expand All @@ -123,9 +122,3 @@ def aerial_24():
print(
'min: %sms | avg: %sms | total: %sms | len: %s <-- %s' %
(min_, avg, elapsed, size, name))


if __name__ == "__main__":
setup()
do_encoding()
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))

0 comments on commit 6a5efb7

Please sign in to comment.