def assertResponse(self, app, method, url, status=None, headers=None, content=None): host, port = 'localhost', 80 http_client_intercept.install() add_wsgi_intercept(host, port, app) client = http_lib.HTTPConnection(host, port) client.request(method, url) response = client.getresponse() if status is not None: self.assertEqual(response.status, status) headers = headers or {} for k, v in headers.items(): self.assertEqual(response.getheader(k), v) if content is not None: self.assertEqual(response.read(), content) client.close() remove_wsgi_intercept(host, port) http_client_intercept.uninstall()
def setup_module(module): # cleanup try: shutil.rmtree('store') except OSError: pass # establish web server app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) # establish store store = Store(config['server_store'][0], config['server_store'][1], environ={'tiddlyweb.config': config}) # make some stuff bag = Bag('place') store.put(bag) for i in range(1, 10): tiddler = Tiddler('tiddler%s' % i, 'place') tiddler.text = 'hi%s' store.put(tiddler) module.http = httplib2.Http()
def setup_intercept(self, callbacks, intercept_api=False): """Setup the WSGI intercepts. `callbacks` have to be provided to call upon request of the intercepted urls. They should be supplied as a dictionary of ((hostname, port), callback). Additionally one extra `default` callback has to be passed in, in the form ('default', callback). The `intercept_api` parameter is used to install the `httplib2` intercepts, used to intercept the lazr.restful api calls. """ self.patch_wsgi_intercept() self.intercepted = [] install_opener() self.intercept_api = intercept_api if intercept_api: install() for key, callback in callbacks.items(): if key == 'default': continue host, port = key add_wsgi_intercept(host, port, callback) self.intercepted.append((host, port))
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('thing.0.0.0.0', 8080, app_fn) module.http = httplib2.Http() make_fake_space(store, 'thing')
def setUp(self): self.cooperative_super('setUp') self.app = self.make_wsgi_app() factory = lambda: AuthorizationMiddleware(self.app) for host in TEST_HOSTS: wsgi_intercept.add_wsgi_intercept(host, 80, factory)
def _initialize_app(tmpdir): # XXX: side-effecty and inscrutable instance_dir = os.path.join(tmpdir, 'instance') spawn(instance_dir, init_config, instance) old_cwd = os.getcwd() os.chdir(instance_dir) # force loading of instance's `tiddlywebconfig.py` while old_cwd in sys.path: sys.path.remove(old_cwd) sys.path.insert(0, os.getcwd()) merge_config(CONFIG, {}, reconfig=True) # XXX: should not be necessary!? CONFIG['server_host'] = { 'scheme': 'http', 'host': 'example.org', 'port': '8001', } # TODO: test with server_prefix # add symlink to templates -- XXX: hacky, should not be necessary!? templates_path = instance.__file__.split(os.path.sep)[:-2] + ['templates'] os.symlink(os.path.sep.join(templates_path), 'templates') httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('example.org', 8001, load_app)
def test_cookie_session_middleware(): user = user_module.User() user._update_data(FAKE_USER_DATA) user_module.thread_locals.current_user = user app = CookieSessionMiddleware(application, b'wtf!', expires=3600, max_age=3600) add_wsgi_intercept(HOST, PORT, lambda: app) response = requests.get(URL) assert response.cookies['leancloud:session'] del user_module.thread_locals.current_user requests.get(URL, cookies=response.cookies) current = user_module.User.get_current() assert current.id == user.id assert current.get_session_token() == user.get_session_token() assert not current._attributes del user_module.thread_locals.current_user response = requests.get(URL + '/logout', cookies=response.cookies) assert 'leancloud:session' not in response.cookies # TODO: try not using for..in to get cookie for cookie in response.cookies: if cookie.name == "leancloud:session": assert cookie.expires assert cookie.max_age break remove_wsgi_intercept()
def setup_module(module): module.store = Store('ramstore', {}, {}) config['server_store'] = ['ramstore', {}] def app_fn(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def setUp(self): ''' Create a new Bottle app set it as default_app and register it to urllib2 ''' self.url = 'http://test:80' self.wsgi = bottle.Bottle() self.oldapp = bottle.default_app() bottle.default_app(self.wsgi) wsgi_intercept.add_wsgi_intercept('test', 80, bottle.default_app)
def setup_module(module): try: shutil.rmtree('store') except: pass # !!! config['server_host'] = { 'host': 'our_test_domain', 'port': '8001', 'scheme': 'http', } from tiddlyweb.web import serve # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return serve.load_app() #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn) environ = {'tiddlyweb.config': config} module.store = Store(config['server_store'][0], config['server_store'][1], environ) admin = User('admin') admin.add_role('ADMIN') admin.set_password('spank') module.store.put(admin) module.admin_authorization = b64encode('admin:spank') module.user_authorization = b64encode('cdent:pigdog')
def test_quoting_issue11(): # see http://code.google.com/p/wsgi-intercept/issues/detail?id=11 http = httplib2.Http() inspected_env = {} def make_path_checking_app(): def path_checking_app(environ, start_response): inspected_env['QUERY_STRING'] = environ['QUERY_STRING'] inspected_env['PATH_INFO'] = environ['PATH_INFO'] status = '200 OK' response_headers = [('Content-type', 'text/plain')] start_response(status, response_headers) return [] return path_checking_app wsgi_intercept.add_wsgi_intercept('some_hopefully_nonexistant_domain', 80, make_path_checking_app) resp, content = http.request( 'http://some_hopefully_nonexistant_domain:80/spaced+words.html?word=something%20spaced', 'GET') assert ('QUERY_STRING' in inspected_env and 'PATH_INFO' in inspected_env), "path_checking_app() was never called?" eq_(inspected_env['PATH_INFO'], '/spaced+words.html') eq_(inspected_env['QUERY_STRING'], 'word=something%20spaced')
def get_storage_args(self, request, get_item, tmpdir, etesync_app): import wsgi_intercept import wsgi_intercept.requests_intercept wsgi_intercept.requests_intercept.install() wsgi_intercept.add_wsgi_intercept("127.0.0.1", 8000, lambda: etesync_app) def teardown(): wsgi_intercept.remove_wsgi_intercept("127.0.0.1", 8000) wsgi_intercept.requests_intercept.uninstall() request.addfinalizer(teardown) with open( os.path.join(os.path.dirname(__file__), "test@localhost/auth_token") ) as f: token = f.read().strip() headers = {"Authorization": "Token " + token} r = requests.post( "http://127.0.0.1:8000/reset/", headers=headers, allow_redirects=False ) assert r.status_code == 200 def inner(collection="test"): rv = { "email": "test@localhost", "db_path": str(tmpdir.join("etesync.db")), "secrets_dir": os.path.dirname(__file__), "server_url": "http://127.0.0.1:8000/", } if collection is not None: rv = self.storage_class.create_collection(collection=collection, **rv) return rv return inner
def initialize_fakes(app): # Set up WSGI interceptor. This sets up a fake host that responds each # time httplib tries to communicate to localhost, port 8779. def wsgi_interceptor(*args, **kwargs): def call_back(env, start_response): path_info = env.get('PATH_INFO') if path_info: env['PATH_INFO'] = urllib.unquote(path_info) #print("%s %s" % (args, kwargs)) return app.__call__(env, start_response) return call_back wsgi_intercept.add_wsgi_intercept('localhost', CONF.bind_port, wsgi_interceptor) # Finally, engage in some truly evil monkey business. We want # to change anything which spawns threads with eventlet to instead simply # put those functions on a queue in memory. Then, we swap out any functions # which might try to take a nap to instead call functions that go through # this queue and call the functions that would normally run in seperate # threads. import eventlet from reddwarf.tests.fakes.common import event_simulator_sleep eventlet.sleep = event_simulator_sleep greenthread.sleep = event_simulator_sleep import time time.sleep = event_simulator_sleep
def setup(self, request, tmpdir): if ver(radicale.VERSION) < ver('2.0.0-pre'): raise RuntimeError('Testing against Radicale only works with ' 'Radicale >= 2.0.0') def get_app(): config = radicale.config.load(()) config.set('storage', 'filesystem_folder', str(tmpdir)) config.set('rights', 'type', 'owner_only') app = radicale.Application(config, logger) def is_authenticated(user, password): return user == 'bob' and password == 'bob' app.is_authenticated = is_authenticated return app wsgi_intercept.requests_intercept.install() wsgi_intercept.add_wsgi_intercept('127.0.0.1', 80, get_app) def teardown(): wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 80) wsgi_intercept.requests_intercept.uninstall() request.addfinalizer(teardown)
def setup_module(module): from paste.script import testapp static_app = StaticURLParser(os.path.join(os.path.dirname(__file__), 'test-static')) wsgi_intercept.add_wsgi_intercept('wsgify.org', 80, lambda : static_app) wsgi_intercept.add_wsgi_intercept('wsgify.org', 9999, lambda : testapp.TestApplication(text=True))
def __init__(self, port=8000): """Initializes the mock server on localhost port 8000. Use urllib2.urlopen('http://localhost:8000') to reach the test server. The constructor takes a 'port=<int>' argument if you want the server to listen on a different port.""" wsgi_intercept.add_wsgi_intercept('localhost', port, self.interceptor) wsgi_urllib2.install_opener()
def test_mozilla_auth(self): if not DO_TESTS: return wsgi_intercept.add_wsgi_intercept('localhost', 80, fake_response) auth = MozillaAuth('ldap://localhost', 'localhost', 'this_path', 'http') auth.create_user('tarek', 'tarek', '*****@*****.**') uid = auth.get_user_id('tarek') auth_uid = auth.authenticate_user('tarek', 'tarek') self.assertEquals(auth_uid, uid) #password change with no old password (sreg) self.assertTrue(auth.generate_reset_code(uid)) self.assertTrue(auth.admin_update_password(uid, 'newpass', key='foo')) #password change with old password (ldap) self.assertTrue(auth.update_password(uid, 'newpass', 'tarek')) auth_uid = auth.authenticate_user('tarek', 'newpass') self.assertEquals(auth_uid, uid) self.assertEquals(auth.get_user_node(uid), 'foo') auth.clear_reset_code(uid) wsgi_intercept.add_wsgi_intercept('localhost', 80, bad_reset_code_resp) self.assertFalse(auth.admin_update_password(uid, 'newpass', key='foo'))
def setup_module(module): module.store = get_store(config) # cascade to deal with differently named files depending on # anydbm impelementation try: os.unlink('links.db') except OSError: pass # not there module.links_manager = LinksManager() try: shutil.rmtree('store') except: pass def app(): return serve.load_app() httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app) # for @someone syntax to test correctly we need a corresponding # recipe module.store.put(Bag('cdent_public')) recipe = Recipe('cdent_public') recipe.set_recipe([('cdent_public', '')]) module.store.put(recipe)
def setUp(self): requests_intercept.install() add_wsgi_intercept("httpbin.org", 80, self.get_app) logging.getLogger("requests").setLevel("ERROR") self.fake_target = fauxfactory.gen_ipaddr() self.service = HttpService(self.fake_target)
def setup_module(module): try: shutil.rmtree('indexdir') shutil.rmtree('store') except: pass app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn) store = get_store(config) test_bag = Bag('editable') try: store.delete(test_bag) except StoreError: pass store.put(test_bag) module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config} module.store = store module.http = httplib2.Http() module.csrf = None
def setup_module(module): make_test_env(module) # we have to have a function that returns the callable, # Selector just _is_ the callable httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.http = httplib2.Http()
def make_intercept(scope='module'): host = 'api.crowdin.com' port = 443 urllib3_intercept.install() add_wsgi_intercept(host, port, lambda: app.wsgi_app) yield None remove_wsgi_intercept()
def intercept_too_many_targets(): targets = ['de_DE', 'es_ES'] app = get_configured_app(target_langs=targets) requests_intercept.install() add_wsgi_intercept(_INTERCEPT_HOST, _INTERCEPT_PORT, lambda: app) yield app remove_wsgi_intercept()
def test_app(environ, start_response): """Simplest possible application object""" url = urlunparse((environ['wsgi.url_scheme'], environ['HTTP_HOST'], environ['PATH_INFO'], '', environ['QUERY_STRING'], '')) key = md5hash(url) status = '200 OK' response_headers = [('Content-type', 'text/xml')] start_response(status, response_headers) global _app_was_hit _app_was_hit = True data_file = os.path.join(os.path.dirname(__file__), 'data', "%s.xml" % key) try: filedata = open(data_file).read() except IOError: #print "\nintercepted: %s" % url #print "key:", key import wsgi_intercept wsgi_intercept.remove_wsgi_intercept('ws.audioscrobbler.com', 80) import urllib2 filedata = urllib2.urlopen(url).read() wsgi_intercept.add_wsgi_intercept('ws.audioscrobbler.com', 80, create_wsgi_app) open(data_file, "w").write(filedata) return [filedata]
def setUp(self): self.db = Database() self.db.update_record('oai:spam', datetime.datetime(2009, 10, 13, 12, 30, 00), False, { 'spam': dict(name='spamset'), 'test': dict(name='testset') }, {'title': ['Spam!']}) self.db.update_record('oai:spamspamspam', datetime.datetime(2009, 0o6, 13, 12, 30, 00), False, {'spam': dict(name='spamset')}, {'title': ['Spam Spam Spam!']}) self.db.update_record('oai:ham', datetime.datetime(2010, 10, 13, 12, 30, 00), False, { 'ham': dict(name='hamset'), 'test': dict(name='testset') }, {'title': ['Ham!']}) self.db.flush() self.config = FeedConfig('Test Server', 'http://test', admin_emails=['testuser@localhost'], metadata_prefixes=['oai_dc', 'mods', 'didl']) self.server = Server('http://test', self.db, self.config) self.app = MOAIWSGIApp(self.server) wsgi_intercept.add_wsgi_intercept('test', 80, lambda: self.app)
def test_app(environ, start_response): """Simplest possible application object""" url = urlunparse(( environ['wsgi.url_scheme'], environ['HTTP_HOST'], environ['PATH_INFO'], '', environ['QUERY_STRING'], '' )) key = md5hash(url) status = '200 OK' response_headers = [('Content-type','text/xml')] start_response(status, response_headers) global _app_was_hit _app_was_hit = True data_file = os.path.join(os.path.dirname(__file__), 'data', "%s.xml" % key) try: filedata = open(data_file).read() except IOError: #print "\nintercepted: %s" % url #print "key:", key import wsgi_intercept wsgi_intercept.remove_wsgi_intercept('ws.audioscrobbler.com', 80) import urllib.request, urllib.error, urllib.parse filedata = urllib.request.urlopen(url).read() wsgi_intercept.add_wsgi_intercept('ws.audioscrobbler.com', 80, create_wsgi_app) open(data_file, "w").write(filedata) return [filedata]
def get_storage_args(self, request, get_item, tmpdir, etesync_app): import wsgi_intercept import wsgi_intercept.requests_intercept wsgi_intercept.requests_intercept.install() wsgi_intercept.add_wsgi_intercept('127.0.0.1', 8000, lambda: etesync_app) def teardown(): wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 8000) wsgi_intercept.requests_intercept.uninstall() request.addfinalizer(teardown) with open(os.path.join(os.path.dirname(__file__), 'test@localhost/auth_token')) as f: token = f.read().strip() headers = {'Authorization': 'Token ' + token} r = requests.post('http://127.0.0.1:8000/reset/', headers=headers, allow_redirects=False) assert r.status_code == 200 def inner(collection='test'): rv = { 'email': 'test@localhost', 'db_path': str(tmpdir.join('etesync.db')), 'secrets_dir': os.path.dirname(__file__), 'server_url': 'http://127.0.0.1:8000/' } if collection is not None: rv = self.storage_class.create_collection( collection=collection, **rv ) return rv return inner
def initialize_app(): app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def browser(db_session, request, setup_app): """ returns an instance of `zope.testbrowser`. The `kotti.testing.user` pytest marker (or `pytest.mark.user`) can be used to pre-authenticate the browser with the given login name: `@user('admin')`. """ from wsgi_intercept import add_wsgi_intercept, zope_testbrowser from kotti.testing import BASE_URL host, port = BASE_URL.split(":")[-2:] add_wsgi_intercept(host[2:], int(port), lambda: setup_app) browser = zope_testbrowser.WSGI_Browser(BASE_URL + "/") if "user" in request.keywords: # set auth cookie directly on the browser instance... from pyramid.security import remember from pyramid.testing import DummyRequest login = request.keywords["user"].args[0] environ = dict(HTTP_HOST=host[2:]) for _, value in remember(DummyRequest(environ=environ), login): cookie, _ = value.split(";", 1) name, value = cookie.split("=") if name in browser.cookies: del browser.cookies[name] browser.cookies.create(name, value.strip('"'), path="/") return browser
def test_reset_code_sreg(self): try: import wsgi_intercept from wsgi_intercept.urllib2_intercept import install_opener install_opener() except ImportError: return def _fake_response(): return Response('0') def _no_email_response(): r = Response() r.status = '400 Bad Request' r.body = str(ERROR_NO_EMAIL_ADDRESS) return r config = {'backend': 'services.resetcodes.rc_sreg.ResetCodeSreg', 'sreg_location': 'localhost', 'sreg_path': '', 'sreg_scheme': 'http'} mgr = load_and_configure(config) user = User() user['userid'] = 1 user['username'] = '******' wsgi_intercept.add_wsgi_intercept('localhost', 80, _fake_response) self.assertRaises(AlreadySentError, mgr.generate_reset_code, user) wsgi_intercept.add_wsgi_intercept('localhost', 80, _no_email_response) self.assertRaises(NoEmailError, mgr.generate_reset_code, user)
def __init__(self, app): self.app = app host = 'example.com' port = 80 self.base = 'http://%s:%d' % (host, port) wsgi_intercept.add_wsgi_intercept(host, port, lambda: self.app) self.opener = urllib2.build_opener(WSGI_HTTPHandler())
def setup_module(module): try: shutil.rmtree('indexdir') shutil.rmtree('store') except: pass app = load_app() def app_fn(): return app requests_intercept.install() wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn) store = get_store(config) test_bag1 = Bag('newtank') try: store.delete(test_bag1) except StoreError: pass test_bag1.policy.accept = ['NONE'] store.put(test_bag1) module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config} module.store = store module.cookie, module.csrf = establish_user_auth(config, store, 'tankt.peermore.com:8080', 'tester')
def test_reset_code_sreg(self): try: import wsgi_intercept from wsgi_intercept.urllib2_intercept import install_opener install_opener() except ImportError: return def _fake_response(): return Response('0') def _no_email_response(): r = Response() r.status = '400 Bad Request' r.body = str(ERROR_NO_EMAIL_ADDRESS) return r config = { 'backend': 'services.resetcodes.rc_sreg.ResetCodeSreg', 'sreg_location': 'localhost', 'sreg_path': '', 'sreg_scheme': 'http' } mgr = load_and_configure(config) user = User() user['userid'] = 1 user['username'] = '******' wsgi_intercept.add_wsgi_intercept('localhost', 80, _fake_response) self.assertRaises(AlreadySentError, mgr.generate_reset_code, user) wsgi_intercept.add_wsgi_intercept('localhost', 80, _no_email_response) self.assertRaises(NoEmailError, mgr.generate_reset_code, user)
def test_cookie_session_middleware(): user = user_module.User() user._update_data(FAKE_USER_DATA) user_module.thread_locals.current_user = user app = CookieSessionMiddleware(application, b"wtf!", expires=3600, max_age=3600) add_wsgi_intercept(HOST, PORT, lambda: app) response = requests.get(URL) assert response.cookies["leancloud:session"] del user_module.thread_locals.current_user requests.get(URL, cookies=response.cookies) current = user_module.User.get_current() assert current.id == user.id assert current.get_session_token() == user.get_session_token() assert not current._attributes del user_module.thread_locals.current_user response = requests.get(URL + "/logout", cookies=response.cookies) assert "leancloud:session" not in response.cookies # TODO: try not using for..in to get cookie for cookie in response.cookies: if cookie.name == "leancloud:session": assert cookie.expires assert cookie.max_age break remove_wsgi_intercept()
def setup_module(module): try: shutil.rmtree('indexdir') shutil.rmtree('store') except: pass app = load_app() def app_fn(): return app requests_intercept.install() wsgi_intercept.add_wsgi_intercept('tankt.peermore.com', 8080, app_fn) store = get_store(config) test_bag1 = Bag('newtank') try: store.delete(test_bag1) except StoreError: pass test_bag1.policy.accept = ['NONE'] store.put(test_bag1) module.environ = {'tiddlyweb.store': store, 'tiddlyweb.config': config} module.store = store module.cookie, module.csrf = establish_user_auth( config, store, 'tankt.peermore.com:8080', 'tester')
def get_storage_args(self, request, tmpdir, slow_create_collection): tmpdir.mkdir('xandikos') backend = XandikosBackend(path=str(tmpdir)) cup = '/user/' backend.create_principal(cup, create_defaults=True) app = XandikosApp(backend, cup) app = WellknownRedirector(app, '/') wsgi_intercept.requests_intercept.install() wsgi_intercept.add_wsgi_intercept('127.0.0.1', 8080, lambda: app) def teardown(): wsgi_intercept.remove_wsgi_intercept('127.0.0.1', 8080) wsgi_intercept.requests_intercept.uninstall() request.addfinalizer(teardown) def inner(collection='test'): url = 'http://127.0.0.1:8080/' args = {'url': url, 'collection': collection} if collection is not None: args = self.storage_class.create_collection(**args) return args return inner
def setup_module(module): make_test_env(module) # we have to have a function that returns the callable, # Selector just _is_ the callable make_fake_space(module.store, 'cdent') httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn)
def setup_module(module): from paste.script import testapp static_app = StaticURLParser( os.path.join(os.path.dirname(__file__), 'test-static')) wsgi_intercept.add_wsgi_intercept('wsgify.org', 80, lambda: static_app) wsgi_intercept.add_wsgi_intercept( 'wsgify.org', 9999, lambda: testapp.TestApplication(text=True))
def setup_module(module): make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) wsgi_intercept.add_wsgi_intercept('cdent.0.0.0.0', 8080, app_fn) module.http = httplib2.Http()
def setup_module(module): global TESTS make_test_env(module) httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn) module.http = httplib2.Http() TESTS = yaml.load(open('../test/httptest.yaml'))
def UnitTestServer(dataset, host='localhost', port=8080, script_name=''): """ A quick fake server for Pydap datasets. """ app = SimpleHandler(dataset) add_wsgi_intercept(host, port, lambda: app, script_name=script_name) return app
def setup_module(module): # we have to have a function that returns the callable, # Selector just _is_ the callable def app_fn(): return serve.load_app() #wsgi_intercept.debuglevel = 1 httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('our_test_domain', 8001, app_fn)
def setUp(self): # Work around circular import. from lp.testing.layers import wsgi_application super(Urllib2Fixture, self).setUp() add_wsgi_intercept('launchpad.dev', 80, lambda: wsgi_application) self.addCleanup(remove_wsgi_intercept, 'launchpad.dev', 80) install_opener() self.addCleanup(uninstall_opener)
def initialize_app(): app = load_app() def app_fn(): return app httplib2_intercept.install() wsgi_intercept.add_wsgi_intercept('0.0.0.0', 8080, app_fn)