Closed
Description
I know I can override container names, but I think the default implementation is bad.
Currently containers are named "pytest{}".format(os.getpid())
. This leads to the following problems:
- If test runs fail or are interrupted (ctrl-c), containers may stay around. Due to the unique names they start to accumulate. Same for images.
- Docker-compose doesn't recognize that things belong to each other, and has conflicts. For example, if you use a static network subnet, then pytest-docker fails as different runs try to use the same network, but it's named separately.
This cost me days to debug (no docker wiz here).
Is there a specific reason why to use the pid-based naming? I would follow simply the behavior of docker-compose:
@pytest.fixture(scope='session')
def docker_compose_project_name(pytestconfig):
""" Generate a project name using the projects root directory.
Override this fixture in your tests if you need a particular project name.
"""
return "{}pytest".format(os.path.basename(str(pytestconfig.rootdir)))
Metadata
Metadata
Assignees
Labels
No labels