My settings.json
<code>{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.rulers": [
80,
]
},
"black-formatter.args": [
"--line-length",
"80"
],
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "off",
"python.envFile": "${workspaceFolder}/.vscode/.env",
// "isort.args":["--profile", "black"]
}
</code>
<code>{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.rulers": [
80,
]
},
"black-formatter.args": [
"--line-length",
"80"
],
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "off",
"python.envFile": "${workspaceFolder}/.vscode/.env",
// "isort.args":["--profile", "black"]
}
</code>
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"[python]": {
"editor.defaultFormatter": "ms-python.autopep8",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll": "explicit"
},
"editor.rulers": [
80,
]
},
"black-formatter.args": [
"--line-length",
"80"
],
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "off",
"python.envFile": "${workspaceFolder}/.vscode/.env",
// "isort.args":["--profile", "black"]
}
I see all tests in Test explorer. I have test postgres database running in a docker container outside of vscode in network host mode on ubuntu.
I have .vscode/.env file with all env variables needed to run a test case.
When I run a test from test_explorer I get error
<code>django.db.utils.IntegrityError: duplicate key value violates unique constraint "user_category_name_key"
DETAIL: Key (name)=(Admin) already exists.
</code>
<code>django.db.utils.IntegrityError: duplicate key value violates unique constraint "user_category_name_key"
DETAIL: Key (name)=(Admin) already exists.
</code>
django.db.utils.IntegrityError: duplicate key value violates unique constraint "user_category_name_key"
DETAIL: Key (name)=(Admin) already exists.
If I try running the same test case through Run and debug
using following launch.json
file – it works successfully
<code>{
"version": "0.2.0",
"configurations": [
{
"name": "Django test",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"test",
"app1.tests.test1.test_abc",
"--keepdb"
],
"django": true,
"envFile": "${workspaceFolder}/.vscode/.env",
"console": "integratedTerminal"
}
]
</code>
<code>{
"version": "0.2.0",
"configurations": [
{
"name": "Django test",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"test",
"app1.tests.test1.test_abc",
"--keepdb"
],
"django": true,
"envFile": "${workspaceFolder}/.vscode/.env",
"console": "integratedTerminal"
}
]
</code>
{
"version": "0.2.0",
"configurations": [
{
"name": "Django test",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/manage.py",
"args": [
"test",
"app1.tests.test1.test_abc",
"--keepdb"
],
"django": true,
"envFile": "${workspaceFolder}/.vscode/.env",
"console": "integratedTerminal"
}
]