我很难让这个简单的测试工作:
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 源代码,您将 an 传递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
字典键名称的文档。