cool-easter-32542
03/18/2025, 4:28 PMdocker_environment target harnessing a Docker image with Postgres installed. In my Python unit tests I can then use pytest-postgresql (https://github.com/dbfixtures/pytest-postgresql), which will use a subprocess to spin up a Postgres database for each test session.
python_tests(
# Will run tests within Docker container with Postgres installed
environment = "py311_postgres",
# Will make sure environment Docker image is built before running tests
runtime_package_dependencies = ["//docker-envs/py311-postgres:image"],
# Run tests in a single batch so we don't need multiple Postgres processes/instances
batch_compatibility_tag = "postgres-db",
...
)
pantsbuild/pants