相关疑难解决方法(0)

Flask 应用程序无法为请求创建 URL 适配器

我有这段代码曾经可以工作:

import unittest

from flask import url_for

from dm.web import create_app, db


class TestApi(unittest.TestCase):
    def setUp(self):
        """Create and configure a new app instance for each test."""
        self.app = create_app('test')
        self.app_context = self.app.app_context()
        self.app_context.push()
        db.create_all()
        self.client = self.app.test_client(use_cookies=True)

    def tearDown(self) -> None:
        db.session.remove()
        db.drop_all()
        self.app_context.pop()

    def test_url(self):
        self.assertEqual('/', url_for('root.home'))

if __name__ == '__main__':
    unittest.main()
Run Code Online (Sandbox Code Playgroud)

但从今天开始我收到了这个错误:

ERROR: test_url (__main__.TestApi)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/joan/.PyCharmCE2019.3/config/scratches/scratch.py", line 17, in test_url
    self.assertEqual('/', url_for('root.home'))
  File "/home/joan/venvs/dimensigon3.7/lib/python3.7/site-packages/flask/helpers.py", line 333, in url_for
    "Application was not …
Run Code Online (Sandbox Code Playgroud)

python flask

7
推荐指数
1
解决办法
7297
查看次数

标签 统计

flask ×1

python ×1