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命令,因为:
- the test runner does not execute
TEST_RUNNER = 'test.test.test'
.
- 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,
},
更多回答
我是一名优秀的程序员,十分优秀!