この簡単なテストを機能させるのに苦労しています:
class TestNotlogedUser(unittest.TestCase):
def setUp(self):
unittest.TestCase.setUp(self)
self.testapp = webtest.TestApp(application)
self.testbed = testbed.Testbed()
self.testbed.activate()
self.testbed.init_datastore_v3_stub()
self.testbed.init_user_stub()
def tearDown(self):
self.testbed.deactivate()
def test_user_profile_301(self):
resp = self.testapp.get('/profile/logout/')
resp.click(linkid='logout') # user logs out
resp = self.testapp.get('/profile/')
self.assertEquals(resp.status_int, 301, resp) # user is redirected to a login page
しかし、それはこのエラーをスローします:
AppError: Bad response: 404 NOT FOUND (not 200 OK or 3xx redirect for http://localhost/accounts/Logout?continue=http%3A//testbed.example.com/)
この部分が問題continue=http%3A//testbed.example.com
なので、ホストを に変更したいですlocalhost:8080
。
githubソースによるextra_environ
と、コンストラクターに渡します:
:param extra_environ:
A dictionary of values that should go
into the environment for each request. These can provide a
communication channel with the application.
私の質問は、このパラメーターの値として変更できることtestbed.example.com
です。まだソースを探していますが、このextra_environ
辞書のキーの名前に関するドキュメントはないようです。