【发布时间】:2019-01-01 19:47:53
【问题描述】:
很难解释。我正在尝试将此字典传递给 final.html 页面,但是当我运行测试时,它会显示“None:None”,就像它从未从高分字典中获取数据一样:
class FlaskTestCase(unittest.TestCase):
highscore = {1:2}
def test_initial_word(self):
with app.app_context():
response = self.app.get("/final", data = dict(self.highscore , user = "test", score = 12))
self.assertIn("quick and easy game", str(response.data))
当我尝试仅使用变量的其他测试时,一切正常:
def test_initial_word(self):#Check if game.html has been created
with app.app_context():
response = self.app.get("/rules", data = dict(user = "test", score = 12))
self.assertIn("test", str(response.data))
我应该如何正确地将字典添加到测试中?
【问题讨论】:
标签: python flask python-unittest