Test Driven Development with Django
- Up
docker compose build
docker compose up -d
- Down
docker compose down
- Down (remove volume)
docker compose down -v
- Re-Build
docker compose up -d --build
```doc
### 2. Run the migrations:
```bash
docker compose exec movies python manage.py migrate --noinput
docker volume inspect django-tdd-docker_postgres_data
docker compose exec movies python manage.py flush
docker compose exec movies python manage.py loaddata movies.json
docker compose exec movies python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
http --json POST http://localhost:8009/api/movies/ title=Fargo genre=comedy year=1996
http --json http://localhost:8009/api/movies/
http --json http://localhost:8009/api/movies/1/
-
Normal run
docker compose exec movies pytest
-
Disable warnings
docker compose exec movies pytest -p no:warnings
-
Run only the last failed tests
docker compose exec movies pytest --lf
-
Run only the tests with names that match the string expression
docker compose exec movies pytest -k "movie and not all_movies"
-
Stop the test session after the first failure
docker compose exec movies pytest -x
-
Enter PDB after first failure then end the test session
docker compose exec movies pytest -x --pdb
-
Stop the test run after two failures
docker compose exec movies pytest --maxfail=2
-
Show local variables in tracebacks
docker compose exec movies pytest -l
-
list the 2 slowest tests
docker compose exec movies pytest --durations=2