Mercurial > hg > simpypi
comparison tests/test.py @ 32:486a4640fc31
fix test harness
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 29 Feb 2012 20:25:19 -0800 |
parents | 90777e79ea13 |
children | 143adebe4caa |
comparison
equal
deleted
inserted
replaced
31:4990fe59974a | 32:486a4640fc31 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 """ | 3 """ |
4 doctest runner | 4 doctest runner for simpypi tests |
5 """ | 5 """ |
6 | 6 |
7 import doctest | 7 import doctest |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import sys | 10 import sys |
11 import tempfile | 11 import tempfile |
12 from optparse import OptionParser | 12 from optparse import OptionParser |
13 from paste.fixture import TestApp | |
14 import simpypi.factory import factory | |
15 | |
16 class SimpypiTestApp(TestApp): | |
17 """WSGI app wrapper for testing simpypi""" | |
18 | |
19 def __init__(self, directory): | |
20 app = factory(directory=directory) | |
21 TestApp.__init__(self, app) | |
22 | 13 |
23 def run_tests(raise_on_error=False, report_first=False): | 14 def run_tests(raise_on_error=False, report_first=False): |
24 | 15 |
25 # add results here | 16 # add results here |
26 results = {} | 17 results = {} |
40 for test in tests: | 31 for test in tests: |
41 | 32 |
42 # make a temporary directory | 33 # make a temporary directory |
43 tmpdir = tempfile.mkdtemp() | 34 tmpdir = tempfile.mkdtemp() |
44 doctest_args['extraglobs']['directory'] = tmpdir | 35 doctest_args['extraglobs']['directory'] = tmpdir |
45 | |
46 # make a test WSGI app | |
47 app = simpypi. | |
48 | 36 |
49 try: | 37 try: |
50 results[test] = doctest.testfile(test, **doctest_args) | 38 results[test] = doctest.testfile(test, **doctest_args) |
51 except doctest.DocTestFailure, failure: | 39 except doctest.DocTestFailure, failure: |
52 raise | 40 raise |