小编con*_*ror的帖子

如何修复“内部错误:在子计划目标列表中找不到变量”

我有一个旧版 Django 项目 (django-1.1.29) 和 pytest (pytest-4.3.0) 中的一些测试,全部在 Docker 内运行。数据库是PostgreSQL 10,是应用程序依赖的docker-compose服务。python版本是2.7.18。

最近测试开始失败并出现一个奇怪的错误:

InternalError: variable not found in subplan target list

仅当我计算某个模型的对象数量时才会出现错误,例如Problem.objects.count()。该指令变成以下查询

(0.000) SELECT COUNT(*) AS "__count" FROM "problems_problem"; args=() 由姜戈.

整个日志在这里:

self = <integration_tests.project_name.subjects.test_views.test_theme_problem_view_set.TestThemeProblemViewSet object at 0x7f01faccbe50>
jclient = <project_name.common.test_utils.json_client.JSONClient object at 0x7f01fadb8ed0>

    def test_all_is_ok(self, jclient, subject_model, content_manager):
        url, data = self._main_prepare(jclient, subject_model, content_manager)
        response = jclient.post_json(url, data[0])
        assert response.status_code == 201
>       assert Problem.objects.count() == 1

integration_tests/project_name/subjects/test_views/test_theme_problem_view_set.py:86: 
_ _ _ _ _ _ _ _ _ …
Run Code Online (Sandbox Code Playgroud)

python django postgresql pytest docker

13
推荐指数
1
解决办法
4978
查看次数

标签 统计

django ×1

docker ×1

postgresql ×1

pytest ×1

python ×1