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

其他格式: JSON · Markdown 中文 · English
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.

generic

解决方案

  1. 95% 成功率
    Move test file to a directory without __init__.py and name it test_*.py
  2. 90% 成功率
    Create an empty conftest.py in the test directory.

无效尝试

常见但无效的做法:

  1. 80% 失败

    This actually can disable assertion rewriting; removing it is better.

  2. 60% 失败

    The assertion still fails, but the message is less informative.