python
config_error
ai_generated
true
断言错误:断言 True == False(此模块的 pytest 断言重写已禁用)
AssertionError: assert True == False (pytest assertion rewriting is disabled for this module)
ID: python/pytest-assertion-rewriting-disabled
80%修复率
82%置信度
0证据数
2024-09-14首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.x | active | — | — | — |
根因分析
测试模块未被 pytest 的断言重写处理,通常是因为它位于带有 __init__.py 的目录中或不在测试文件中。
English
The test module is not being processed by pytest's assertion rewriting, often because it's in a directory with __init__.py or not in a test file.
解决方案
-
95% 成功率
Move test file to a directory without __init__.py and name it test_*.py
-
90% 成功率
Create an empty conftest.py in the test directory.
无效尝试
常见但无效的做法:
-
80% 失败
This actually can disable assertion rewriting; removing it is better.
-
60% 失败
The assertion still fails, but the message is less informative.