python
module_error
ai_generated
true
属性错误:TestLoader 对象没有 loadTestsFromName 属性
AttributeError: 'TestLoader' object has no attribute 'loadTestsFromName'
ID: python/unittest-testloader-error
80%修复率
82%置信度
0证据数
2024-12-01首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 3.12 | active | — | — | — |
根因分析
在 Python 3.12 中,TestLoader 的方法名可能已更改或已弃用
English
在 Python 3.12 中,TestLoader 的方法名可能已更改或已弃用
解决方案
-
90% 成功率
loader = unittest.TestLoader(); suite = loader.loadTestsFromTestCase(MyTest)
-
85% 成功率
suite = unittest.defaultTestLoader.discover('tests')
无效尝试
常见但无效的做法:
-
90% 失败
新版本已移除
-
40% 失败
失去动态加载功能