Reusable Containers
Previously reusable containers were never replaced. Once they existed, that was it. So if you changed the fixture in code you had to manually clean up the previous fixture before continuing. This becomes even more annoying if you want to use this feature in your CI environment. This release tracks how stale a docker fixture is and replaces it if it becomes stale. This automatically handles the following cases:
- Your co-worker has bumped a tag in a
fetch()
fixture, for example to use postgres 14 and its new JSON syntax. You git pull and your tests start failing. Sometimes this might not be obvious and the breakage might be some time after the root cause. - You make a change to some code that triggers a
build()
fixture. Right now the build will still run, but the old container with the old image will be used.
In these sorts of situations instead of reusable containers saving you time, they cost time. And if the root cause isn't obvious, it might be a lot of time.
pytest-docker-tools now tags fixtures it makes with the label pytest-docker-tools.signature
. This is a hash of the parameters used to create the fixture. When this signature changes, pytest-docker-tools knows the fixture is stale and replaces it.
⚠️ This is a breaking change. No code changes are needed to use 3.0.0, but existing reusable containers may be deleted and recreated automatically as they will be considered stale by the new code.