Home | History | Annotate | Download | only in tests
      1 from paste.fixture import *
      2 try:
      3     from paste.debug.profile import *
      4     disable = False
      5 except ImportError:
      6     disable = True
      7 
      8 if not disable:
      9     def simple_app(environ, start_response):
     10         start_response('200 OK', [('content-type', 'text/html')])
     11         return ['all ok']
     12 
     13     def long_func():
     14         for i in range(1000):
     15             pass
     16         return 'test'
     17 
     18     def test_profile():
     19         app = TestApp(ProfileMiddleware(simple_app, {}))
     20         res = app.get('/')
     21         # The original app:
     22         res.mustcontain('all ok')
     23         # The profile information:
     24         res.mustcontain('<pre')
     25 
     26     def test_decorator():
     27         value = profile_decorator()(long_func)()
     28         assert value == 'test'
     29 
     30