当我访问/user/member
时,我被重定向,我看到以下消息:
但是,当我在我的unittest中运行此代码时:
import unittest
from portal import app
from portal.config import TestingConfig
from portal.models import db
class BaseTestCase(unittest.TestCase):
def setUp(self):
self.app = app
self.app.config.from_object(TestingConfig)
self.app_context = self.app.app_context()
self.client = app.test_client()
self.app_context.push()
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
self.app_context.pop()
class AccessControlTest(BaseTestCase):
def test_anon_cannot_visit_members_or_admin(self):
u = '/user/member'
r = self.client.get(u, follow_redirects=True)
assert 'You must be signed in' in r.data
我收到错误,找不到文字......
我将渲染的r.data保存到浏览器中,我看到flash消息丢失了: