0
일부 로직과 flash()
을 가진 끝 점이 있고 다른 끝점으로 리디렉션되어 다른 플래시를 추가하고 플래시 된 두 메시지를 표시합니다. 브라우저에서 엔드 포인트를 테스트 할 때 두 메시지가 모두 표시됩니다. 그러나, 내가 나의 unittest를 할 때, 첫번째 플래시가 나타나지 않는다.유닛 테스트 중에 플래시가 작동하지 않음
@bp.route('/signup/', methods=['POST'])
def signup():
form = SignupForm(prefix='signup')
next_url = url_for('.home')
if form.validate_on_submit():
# do stuff like add to waiting list
person = persons.new()
form.populate_obj(person)
person = persons.save(person)
flash(Markup(u'Thanks for signing up!'), 'success')
return redirect(next_url)
@bp.route('/')
def home():
flash('This is home', 'info')
return render_template('home.html')
class PageTests(MTestCase):
def test_signup(self):
r = self.post('/signup/',
data={
'signup-email': '[email protected]',
})
person = persons.find(email='[email protected]').first()
self.assertIsNotNone(person)
self.assertIn('Thanks for signing up', r.data)
리디렉션 중에 플래시 대기열이 손실되었다고 추측합니다.하지만 어떻게 또는 왜 그렇게 확실하지 않습니다.