python config_error ai_generated true

AssertionError: assert True == False (pytest assertion rewriting is disabled for this module)

ID: python/pytest-assertion-rewriting-disabled

Also available as: JSON · Markdown · 中文
80%Fix Rate
82%Confidence
0Evidence
2024-09-14First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.x active

Root Cause

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

中文

测试模块未被 pytest 的断言重写处理,通常是因为它位于带有 __init__.py 的目录中或不在测试文件中。

Workarounds

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

Dead Ends

Common approaches that don't work:

  1. 80% fail

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

  2. 60% fail

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