Issue: Test Explorer shows "No tests found"
Root Causes:
- pytest is not installed
- Existing test files (
execution/scripts/test_*.py) are scripts, not pytest tests - No
tests/directory structure
pip install pytest pytest-covAfter installing pytest, reload VS Code (Cmd+Shift+P → "Developer: Reload Window")
VS Code should now discover tests in:
execution/scripts/test_*.py(if they're proper pytest tests)- Any
tests/directory - Files matching
*_test.pyortest_*.pypatterns
Current test files like test_mytasks_section_alternative.py are scripts, not pytest tests.
def test_alternative_approaches():
"""Test alternative ways..."""
config = AsanaConfig.from_env()
# ... code ...
print("Results...")
if __name__ == "__main__":
test_alternative_approaches()import pytest
def test_alternative_approaches():
"""Test alternative ways..."""
config = AsanaConfig.from_env()
# ... code ...
assert result is not None # Use assertions instead of print
# pytest will capture print output automaticallyKey Changes:
- Add
import pytest(optional but recommended) - Use
assertstatements instead ofprintfor validation - Remove
if __name__ == "__main__"block - pytest will run the function automatically
personal/
├── tests/
│ ├── __init__.py
│ ├── unit/
│ │ ├── __init__.py
│ │ └── test_*.py
│ └── integration/
│ ├── __init__.py
│ └── test_*.py
└── pyproject.toml
mkdir -p tests/unit tests/integration
touch tests/__init__.py tests/unit/__init__.py tests/integration/__init__.py[tool.pytest.ini_options]
testpaths = [
"tests",
"execution/scripts",
"scripts",
]
python_files = ["*_test.py", "test_*.py"]
python_classes = ["Test*"]
python_functions = ["test_*"]{
"python.testing.pytestEnabled": true,
"python.testing.autoTestDiscoverOnSaveEnabled": true
}- Use Test Explorer panel
- Click play icon next to test
- Or use CodeLens (run/debug links above test functions)
# Run all tests
pytest
# Run specific file
pytest execution/scripts/test_mytasks_section_alternative.py
# Run with coverage
pytest --cov=. --cov-report=term-missing
# Verbose output
pytest -v- Install pytest:
pip install pytest pytest-cov - Reload VS Code to enable test discovery
- Convert existing test scripts to pytest format (optional)
- Create
tests/directory for new tests (recommended)
/foundation-config.yaml- Testing configuration/pyproject.toml- Pytest settings/docs/linting-guide.md- Linting setup