Mercurial > hg > simpypi
comparison tests/test.py @ 9:9879140a2026
begin stubbing test app
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Tue, 28 Feb 2012 13:54:21 -0800 |
parents | 15c7171941ea |
children | 90777e79ea13 |
comparison
equal
deleted
inserted
replaced
8:15c7171941ea | 9:9879140a2026 |
---|---|
5 """ | 5 """ |
6 | 6 |
7 import doctest | 7 import doctest |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import simpypi | |
10 import sys | 11 import sys |
11 import tempfile | 12 import tempfile |
12 from optparse import OptionParser | 13 from optparse import OptionParser |
13 from paste.fixture import TestApp | 14 from paste.fixture import TestApp |
15 | |
16 class SimpypiTestApp(TestApp): | |
17 """WSGI app wrapper for testing simpypi""" | |
18 | |
19 | |
14 | 20 |
15 def run_tests(raise_on_error=False, report_first=False): | 21 def run_tests(raise_on_error=False, report_first=False): |
16 | 22 |
17 # add results here | 23 # add results here |
18 results = {} | 24 results = {} |
32 for test in tests: | 38 for test in tests: |
33 | 39 |
34 # make a temporary directory | 40 # make a temporary directory |
35 tmpdir = tempfile.mkdtemp() | 41 tmpdir = tempfile.mkdtemp() |
36 doctest_args['extraglobs']['directory'] = tmpdir | 42 doctest_args['extraglobs']['directory'] = tmpdir |
43 | |
44 # make a test WSGI app | |
45 app = simpypi. | |
37 | 46 |
38 try: | 47 try: |
39 results[test] = doctest.testfile(test, **doctest_args) | 48 results[test] = doctest.testfile(test, **doctest_args) |
40 except doctest.DocTestFailure, failure: | 49 except doctest.DocTestFailure, failure: |
41 raise | 50 raise |
61 | 70 |
62 # run the tests | 71 # run the tests |
63 results = run_tests(**options.__dict__) | 72 results = run_tests(**options.__dict__) |
64 if sum([i.failed for i in results.values()]): | 73 if sum([i.failed for i in results.values()]): |
65 sys.exit(1) # error | 74 sys.exit(1) # error |
66 | |
67 | 75 |
68 if __name__ == '__main__': | 76 if __name__ == '__main__': |
69 main() | 77 main() |
70 | 78 |