@@ -146,30 +146,57 @@ DataJoint (<https://datajoint.com>).
146146
147147# ## Prerequisites
148148
149- - [Docker](https://docs.docker.com/get-docker/) for MySQL and MinIO services
149+ - [Docker](https://docs.docker.com/get-docker/) (Docker daemon must be running)
150150- Python 3.10+
151151
152- # ## Running Tests
153-
154- Tests are organized into ` unit/` (no external services) and ` integration/` (requires MySQL + MinIO):
152+ # ## Quick Start
155153
156154` ` ` bash
157- # Install dependencies
155+ # Clone and install
156+ git clone https://github.com/datajoint/datajoint-python.git
157+ cd datajoint-python
158158pip install -e " .[test]"
159159
160- # Run unit tests only (fast, no Docker needed )
161- pytest tests/unit/
160+ # Run all tests (containers start automatically via testcontainers )
161+ pytest tests/
162162
163- # Start MySQL and MinIO for integration tests
164- docker compose up -d db minio
163+ # Install and run pre-commit hooks
164+ pip install pre-commit
165+ pre-commit install
166+ pre-commit run --all-files
167+ ` ` `
165168
166- # Run all tests
169+ # ## Running Tests
170+
171+ Tests use [testcontainers](https://testcontainers.com/) to automatically manage MySQL and MinIO containers.
172+ ** No manual ` docker-compose up` required** - containers start when tests run and stop afterward.
173+
174+ ` ` ` bash
175+ # Run all tests (recommended)
167176pytest tests/
168177
178+ # Run with coverage report
179+ pytest --cov-report term-missing --cov=datajoint tests/
180+
169181# Run specific test file
170182pytest tests/integration/test_blob.py -v
171183
172- # Stop services when done
184+ # Run only unit tests (no containers needed)
185+ pytest tests/unit/
186+ ` ` `
187+
188+ # ## Alternative: External Containers
189+
190+ For development/debugging, you may prefer persistent containers that survive test runs:
191+
192+ ` ` ` bash
193+ # Start containers manually
194+ docker compose up -d db minio
195+
196+ # Run tests using external containers
197+ DJ_USE_EXTERNAL_CONTAINERS=1 pytest tests/
198+
199+ # Stop containers when done
173200docker compose down
174201` ` `
175202
@@ -183,24 +210,46 @@ docker compose --profile test up djtest --build
183210
184211# ## Alternative: Using pixi
185212
186- [pixi](https://pixi.sh) users can run tests with automatic service management :
213+ [pixi](https://pixi.sh) users can run tests with:
187214
188215` ` ` bash
189216pixi install # First time setup
190- pixi run test # Starts services and runs tests
191- pixi run services-down # Stop services
217+ pixi run test # Runs tests (testcontainers manages containers)
192218` ` `
193219
194220# ## Pre-commit Hooks
195221
222+ Pre-commit hooks run automatically on ` git commit` to check code quality.
223+ ** All hooks must pass before committing.**
224+
196225` ` ` bash
197- pre-commit install # Install hooks (first time)
198- pre-commit run --all-files # Run all checks
226+ # Install hooks (first time only)
227+ pip install pre-commit
228+ pre-commit install
229+
230+ # Run all checks manually
231+ pre-commit run --all-files
232+
233+ # Run specific hook
234+ pre-commit run ruff --all-files
235+ pre-commit run codespell --all-files
199236` ` `
200237
238+ Hooks include:
239+ - ** ruff** : Python linting and formatting
240+ - ** codespell** : Spell checking
241+ - ** YAML/JSON/TOML validation**
242+ - ** Large file detection**
243+
244+ # ## Before Submitting a PR
245+
246+ 1. ** Run all tests** : ` pytest tests/`
247+ 2. ** Run pre-commit** : ` pre-commit run --all-files`
248+ 3. ** Check coverage** : ` pytest --cov-report term-missing --cov=datajoint tests/`
249+
201250# ## Environment Variables
202251
203- Tests use these defaults (configured in ` pyproject.toml ` ):
252+ For external container mode ( ` DJ_USE_EXTERNAL_CONTAINERS=1 ` ):
204253
205254| Variable | Default | Description |
206255| ----------| ---------| -------------|
0 commit comments