@app.route('/view', methods=['GET', 'POST'])
def view_notifications():
posts = get_notifications()
return render_template("frontend/src/view_notifications.html", posts=posts)
Run Code Online (Sandbox Code Playgroud)
所以在我project/backend/src/app.py的代码中.我如何引用project/frontend/src/view_notifications.html我尝试使用的模板,..但它一直在说找不到路径.还有另一种方法我应该这样做吗?
[Tue Jun 23 12:56:02.597207 2015] [wsgi:error] [pid 2736:tid 140166294406912] [remote 10.0.2.2:248] TemplateNotFound: frontend/src/view_notifications.html
[Tue Jun 23 12:56:05.508462 2015] [mpm_event:notice] [pid 2734:tid 140166614526016] AH00491: caught SIGTERM, shutting down
Run Code Online (Sandbox Code Playgroud) 我有一个特定的测试用例,其中我使用了 celery 后端,因此我需要将 task_always_eager 设置为 false,否则我将收到 RuntimeError。然而,问题是我需要在设置为 true 的情况下运行所有其他测试用例,因此我尝试使用 celery 标记注释将 celery 配置 task_always_eager 设置为 false 仅用于此测试用例。然而,它看起来并没有做任何事情。
这是我的任务的骨架:
@pytest.mark.celery(task_always_eager=False)
def test_task(self):
# do some stuff to start a task
do_stuff()
# do some stuff to get info on a task
get_info()
# assertions
Run Code Online (Sandbox Code Playgroud)
错误:
def _ensure_not_eager(self):
if self.app.conf.task_always_eager:
raise RuntimeError(
"Cannot retrieve result with task_always_eager enabled")
E RuntimeError: Cannot retrieve result with task_always_eager enabled
/usr/local/lib/python3.6/site-packages/celery/backends/base.py:334: RuntimeError
Run Code Online (Sandbox Code Playgroud)
TLDR:在这个测试用例中我做错了什么将 task_always_eager 设置为 false 因为它在测试运行时没有改变它?