def test_intercept(): global _app_was_hit _app_was_hit = False twill.add_wsgi_intercept('localhost', 80, lambda: wsgi_lint(simple_app)) assert not _app_was_hit print 'go' twill.commands.go('http://localhost:80/') twill.commands.show() print 'find' twill.commands.find("WSGI intercept successful") assert _app_was_hit print 'remove' twill.remove_wsgi_intercept('localhost', 80)
def test_wrapper_intercept(): """ This tests a tricky wsgi_intercept interaction between the 'write' fn passed back from the start_response function in WSGI, and the generator data yielded from the initial app call. See wsgi_intercept.py, section containing 'generator_data', for more info. """ global _app_was_hit _app_was_hit = False wrap_app = wrapper_app(write_app) twill.add_wsgi_intercept('localhost', 80, lambda: wsgi_lint(wrap_app)) assert not _app_was_hit print 'go' twill.commands.go('http://localhost:80/') print 'find' twill.commands.find("WSGI intercept successful") assert _app_was_hit print 'remove' twill.remove_wsgi_intercept('localhost', 80)