python / python/cpython

The `unittest` `-b` command line option hides the output of `pdb`.

未关闭
#133,691 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

pending stdlib type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:
import unittest

class Test(unittest.TestCase):
    def test(self):
        print("hello")
        breakpoint()
        print("goodbye")

If I invoke this like:

$ python3 -m unittest -b repo.py

Nothing is printed and the process sits waiting on input.

Whereas without the -b option we get the Pdb prompt:

$ python3 -m unittest repo.py 
hello
> /home/matthew/code/coveragepy_issue_1963/repo.py(7)test()
-> print("goodbye")
(Pdb) 

I would expect that the debugger prompt would not be swallowed up by the "-b" option, or that some error message would pop up saying that the "-b" option and the debugger were incompatible.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行报告中的复现命令 python3 -m unittest -b repo.py,并将其与不使用缓冲的命令进行比较。跟踪 unittest 的 -b 输出缓冲如何与 breakpoint() 和 pdb 交互,然后为这种交互添加覆盖;当调试器提示符可用,或产生明确的不兼容错误时,即表示完成。

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

评估

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

把新 issue 发到你的邮箱

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