gpt4 book ai didi

vscode's testing interface does not work properly with django(Vscode的测试接口无法与Django一起正常工作)

转载 作者:bug小助手 更新时间:2023-10-25 21:37:00 38 4
gpt4 key购买 nike



unittest does not create a test database and runs on the production database.

Unittest不创建测试数据库,而是在生产数据库上运行。


`"python.testing.unittestEnabled": true,`

pytest creates a test database but fails with psycopg2.errors.DuplicateDatabase, if the database was not manually deleted.

如果未手动删除数据库,则pytest会创建一个测试数据库,但会失败,并显示opCopg2.errors.DuplicateDatabase。


`"python.testing.pytestEnabled": false,`

Both also don't seem to run django manage.py command since:

这两个命令似乎也都不运行Django Manage.py命令,因为:



  1. the test runner does not execute TEST_RUNNER = 'test.test.test'.

  2. the overridden test Command class does not run either.


    "python.testing.pytestArgs": [
"-v",
"./app1/tests.py",
"./app2/tests.py",
],

  "python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"tests.py"
],

Note that the following launch command in launch.json works 100% properly (test runner and command execute) and all tests run and pass correctly but I would like to use the vscode testing interface.

注意,Launch.json中的以下启动命令100%正常工作(测试运行器和命令执行),并且所有测试都正确运行和通过,但我想使用vscode测试接口。


        {
"name": "Test",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"test",
"-v"
],
"envFile": "${workspaceFolder}/.env",
"django": true,
"justMyCode": false,
},

更多回答
优秀答案推荐
更多回答

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com