The spec_tests directory contains integration tests that validate the HED Python library against the official HED specification and example datasets. These tests are run separately from the main unit tests.
To run spec_tests locally, you need to have the following directory structure:
spec_tests/
├── hed-specification/
│ └── tests/
│ └── json_tests/ # JSON test files for error validation
├── hed-examples/
│ └── datasets/ # BIDS datasets for validation testing
├── test_sidecar.json # Already present
├── test_errors.py # Tests HED validation against spec
├── test_hed_cache.py # Tests HED schema caching
└── validate_bids.py # Tests BIDS dataset validation
-
Copy Submodule Content:
- Copy the content of the
hed-specificationrepository tospec_tests/hed-specification/ - Copy the content of the
hed-examplesrepository tospec_tests/hed-examples/
- Copy the content of the
-
Verify Setup:
- Run
python spec_tests/check_setup.pyto verify all required directories exist
- Run
# Run all spec tests
python -m unittest discover spec_tests -v
# Run specific spec test file
python -m unittest spec_tests.test_hed_cache -v-
Right-click Method:
- Right-click on the
spec_testsfolder in VS Code Explorer - Select "Run Tests" from the context menu
- Right-click on the
-
Using Tasks:
- Open Command Palette (Ctrl+Shift+P)
- Type "Tasks: Run Task"
- Select "Run Spec Tests"
-
Test Explorer:
- Open the Test Explorer panel
- Tests should be discovered in both
tests/andspec_tests/directories
- The
test_hed_cache.pytests should work immediately as they don't require the submodule content - The
test_errors.pyandvalidate_bids.pytests require the submodule content to be present - On GitHub Actions, the submodules are automatically checked out, but locally you need to copy the content manually
If spec tests aren't showing up in VS Code:
- Make sure VS Code Python extension is installed
- Ensure the workspace Python interpreter is set to
.venv/Scripts/python.exe - Try refreshing the test discovery: Command Palette → "Test: Refresh Tests"
- Check that the required directory structure exists using the check script