VScode can now test hurray

This commit is contained in:
Jonas Linter
2025-10-08 16:14:00 +02:00
parent 52f95bd677
commit 44abe3ed35
3 changed files with 62 additions and 22 deletions

38
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,38 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Tests",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"purpose": [
"debug-test"
],
"console": "integratedTerminal",
"justMyCode": false,
"env": {
"PYTEST_ADDOPTS": "--no-cov"
}
},
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Python: API Server",
"type": "debugpy",
"request": "launch",
"module": "alpine_bits_python.run_api",
"console": "integratedTerminal",
"justMyCode": true,
"env": {
"ALPINEBITS_CONFIG_DIR": "${workspaceFolder}/config"
}
}
]
}

33
.vscode/settings.json vendored
View File

@@ -18,7 +18,17 @@
"notebook.output.wordWrap": true, "notebook.output.wordWrap": true,
"notebook.output.textLineLimit": 200, "notebook.output.textLineLimit": 200,
"jupyter.debugJustMyCode": false, "jupyter.debugJustMyCode": false,
"python.defaultInterpreterPath": "./.venv/bin/python",
"python.testing.pytestEnabled": true, "python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"tests",
"-v",
"--tb=short"
],
"python.testing.pytestPath": "./.venv/bin/pytest",
"python.testing.unittestEnabled": false,
"python.testing.autoTestDiscoverOnSaveEnabled": true,
"python.testing.cwd": "${workspaceFolder}",
"files.exclude": { "files.exclude": {
"**/*.egg-info": true, "**/*.egg-info": true,
"**/htmlcov": true, "**/htmlcov": true,
@@ -27,27 +37,6 @@
"**/.venv": true, "**/.venv": true,
"**/__pycache__": true, "**/__pycache__": true,
"**/.mypy_cache": true, "**/.mypy_cache": true,
"**/.pytest_cache": true, "**/.pytest_cache": true
} }
}
// .vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Debug Tests",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"purpose": [
"debug-test"
],
"console": "integratedTerminal",
"justMyCode": false,
"env": {
"PYTEST_ADDOPTS": "--no-cov"
}
}
]
} }

13
conftest.py Normal file
View File

@@ -0,0 +1,13 @@
"""Pytest configuration and path setup for VS Code.
This configuration file ensures that VS Code can properly discover and run tests
by setting up the Python path to include the src directory.
"""
import sys
from pathlib import Path
# Add the src directory to Python path for VS Code test discovery
src_path = Path(__file__).parent / "src"
if str(src_path) not in sys.path:
sys.path.insert(0, str(src_path))