Skip to content
Discussion options

You must be logged in to vote

What I ended up doing is using a docker_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 = "postgre…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@peter-woyzbun
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by peter-woyzbun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants