testcontainers / testcontainers/testcontainers-python

Allow option to keep the containers alive

未关闭
#109 18 条评论 23 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

🐣 good first issue 🤝 contributions are welcome 🛟 help wanted
主要语言
Python
星标
2.3k
派生
386
平均合并
4 小时 40 分钟
30 天内合并 PR
1

描述

It would be nice to keep the docker containers alive for speeding up the test runs. Now, in every test run containers are re-created and can't keep them alive since this block

  def __del__(self):
        """
        Try to remove the container in all circumstances
        """
        if self._container is not None:
            try:
                self.stop()
            except:  # noqa: E722
                pass

removes containers when the instance variable is deleted (when the program terminates) and I cannot override it because this also runs without using with as block.

I don't want my Mysql container to be recreated everytime. I am running tests very frequently and I am waiting couple seconds everytime. Pretty annoying.

I can make a small PR if that makes sense?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先阅读 del 方法附近的 testcontainers/core/container.py,并跟踪测试运行结束时容器如何停止,包括在 with 块之外的使用。定义该选项对于上下文管理的容器和直接创建的容器的生命周期行为;完成的标准是调用方可以让 MySQL 容器在多次运行之间保持存活,而不会自动清理。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, python
领域
devops, testing
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。