comparison MoinMoin/conftest.py @ 4217:b231877df090

Added werkzeug.test.Client for blackbox application testing (headers, status, output)
author Florian Krupicka <florian.krupicka@googlemail.com>
date Mon, 14 Jul 2008 13:16:57 +0200
parents 1ca179133f01
children 4476d5ca521c
comparison
equal deleted inserted replaced
4216:84cdf829d881 4217:b231877df090
23 from sys import modules 23 from sys import modules
24 import sys 24 import sys
25 25
26 import py 26 import py
27 27
28 from werkzeug.test import Client
28 29
29 rootdir = py.magic.autopath().dirpath() 30 rootdir = py.magic.autopath().dirpath()
30 moindir = rootdir.join("..") 31 moindir = rootdir.join("..")
31 32
32 sys.path.insert(0, str(moindir)) 33 sys.path.insert(0, str(moindir))
35 36
36 sys.path.insert(0, str(moindir.join("tests"))) 37 sys.path.insert(0, str(moindir.join("tests")))
37 38
38 from MoinMoin.support.python_compatibility import set 39 from MoinMoin.support.python_compatibility import set
39 from MoinMoin.web.request import TestRequest 40 from MoinMoin.web.request import TestRequest
40 from MoinMoin.wsgiapp import init as request_init 41 from MoinMoin.wsgiapp import application, init
41 42
42 coverage_modules = set() 43 coverage_modules = set()
43 44
44 45
45 try: 46 try:
61 def callback(option, opt_str, value, parser): 62 def callback(option, opt_str, value, parser):
62 atexit.register(report_coverage) 63 atexit.register(report_coverage)
63 coverage.erase() 64 coverage.erase()
64 coverage.start() 65 coverage.start()
65 66
66
67 py.test.config.addoptions('MoinMoin options', py.test.config.Option('-C', 67 py.test.config.addoptions('MoinMoin options', py.test.config.Option('-C',
68 '--coverage', action='callback', callback=callback, 68 '--coverage', action='callback', callback=callback,
69 help='Output information about code coverage (slow!)')) 69 help='Output information about code coverage (slow!)'))
70 70
71 except ImportError: 71 except ImportError:
75 def init_test_request(static_state=[False]): 75 def init_test_request(static_state=[False]):
76 if not static_state[0]: 76 if not static_state[0]:
77 maketestwiki.run(True) 77 maketestwiki.run(True)
78 static_state[0] = True 78 static_state[0] = True
79 request = TestRequest() 79 request = TestRequest()
80 request = request_init(request) 80 request = init(request)
81 return request 81 return request
82 82
83 class TestConfig: 83 class TestConfig:
84 """ Custom configuration for unit tests 84 """ Custom configuration for unit tests
85 85
175 175
176 def setup(self): 176 def setup(self):
177 cls = self.obj 177 cls = self.obj
178 cls.request = self.parent.request 178 cls.request = self.parent.request
179 cls.TestConfig = TestConfig(cls.request) 179 cls.TestConfig = TestConfig(cls.request)
180 cls.client = Client(application)
180 super(MoinClassCollector, self).setup() 181 super(MoinClassCollector, self).setup()
181 182
182 183
183 class Module(py.test.collect.Module): 184 class Module(py.test.collect.Module):
184 Class = MoinClassCollector 185 Class = MoinClassCollector