Skip to content

Commit 6a5efb7

Browse files
committed
Add makefile for short test command lines (cf #45)
Also make test/python_tests/image_encoding_speed_test.py compliant with nosetest runner.
1 parent 91f8b79 commit 6a5efb7

File tree

3 files changed

+32
-13
lines changed

3 files changed

+32
-13
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ mapnik/paths.py
1818
.mason/
1919
mason_packages/
2020
mapnik/plugins
21+
.noseids

Makefile

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.PHONY: help test test_verbose tdd test_failed
2+
3+
TEST := nosetests --logging-clear-handlers --with-id
4+
5+
help:
6+
@echo "Please use \`make <target>' where <target> is one of"
7+
@echo " test to run all the test suite"
8+
@echo " test_verbose to run all the test suite without output capture"
9+
@echo " tdd to run all the test suite, but stop on the first error"
10+
@echo " test_failed to rerun the failed tests from the previous run"
11+
12+
test:
13+
$(TEST) $(filter-out $@,$(MAKECMDGOALS))
14+
15+
test_verbose:
16+
$(TEST) -s $(filter-out $@,$(MAKECMDGOALS))
17+
18+
tdd:
19+
$(TEST) --stop --pdb $(filter-out $@,$(MAKECMDGOALS))
20+
21+
test_failed:
22+
python setup.py nosetests --logging-clear-handlers --with-id -vv --failed $(ARGS)
23+
24+
$(phony %):
25+
@:

test/python_tests/image_encoding_speed_test.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
from timeit import Timer, time
66

77
import mapnik
8-
9-
from .utilities import execution_path, run_all
8+
from .utilities import execution_path
109

1110

1211
def setup():
@@ -60,7 +59,7 @@ def setup():
6059
iterations = 10
6160

6261

63-
def do_encoding():
62+
def test_encoding():
6463

6564
global image
6665

@@ -85,7 +84,7 @@ def blank():
8584
blank_im = mapnik.Image(512, 512)
8685
for c in combinations:
8786
t = Timer(blank)
88-
run(blank, blank_im, c, t)
87+
yield run, blank, blank_im, c, t
8988

9089
if 'solid' in tiles:
9190
def solid():
@@ -94,7 +93,7 @@ def solid():
9493
solid_im.fill(mapnik.Color("#f2efe9"))
9594
for c in combinations:
9695
t = Timer(solid)
97-
run(solid, solid_im, c, t)
96+
yield run, solid, solid_im, c, t
9897

9998
if 'many_colors' in tiles:
10099
def many_colors():
@@ -103,15 +102,15 @@ def many_colors():
103102
many_colors_im = mapnik.Image.open('../data/images/13_4194_2747.png')
104103
for c in combinations:
105104
t = Timer(many_colors)
106-
run(many_colors, many_colors_im, c, t)
105+
yield run, many_colors, many_colors_im, c, t
107106

108107
if 'aerial_24' in tiles:
109108
def aerial_24():
110109
return eval('image.tostring("%s")' % c)
111110
aerial_24_im = mapnik.Image.open('../data/images/12_654_1580.png')
112111
for c in combinations:
113112
t = Timer(aerial_24)
114-
run(aerial_24, aerial_24_im, c, t)
113+
yield run, aerial_24, aerial_24_im, c, t
115114

116115
for key, value in sorted(sortable.items(), key=lambda i: (i[1], i[0])):
117116
s = results[key]
@@ -123,9 +122,3 @@ def aerial_24():
123122
print(
124123
'min: %sms | avg: %sms | total: %sms | len: %s <-- %s' %
125124
(min_, avg, elapsed, size, name))
126-
127-
128-
if __name__ == "__main__":
129-
setup()
130-
do_encoding()
131-
exit(run_all(eval(x) for x in dir() if x.startswith("test_")))

0 commit comments

Comments
 (0)