Files
noteflow/.claude/hookify.block-assertion-roulette.local.md

1.6 KiB

name, enabled, event, action, conditions
name enabled event action conditions
block-assertion-roulette true file block
field operator pattern
file_path regex_match tests?/.*.py$
field operator pattern
new_text regex_match ^\s*assert\s+[^,\n]+\n\s*assert\s+[^,\n]+$

🚫 Test Quality Violation: Assertion Roulette Detected

Your edit contains multiple consecutive assertions without messages - this is called "assertion roulette".

Why this is problematic:

  • When a test fails, you can't tell which assertion failed without reading the stack trace
  • Makes debugging harder, especially in CI logs
  • Multiple assertions hide which specific check failed
  • Violates the project's test quality standards (see tests/quality/)

Example of assertion roulette (BAD):

def test_user_creation():
    user = create_user("alice")
    assert user.name == "alice"
    assert user.is_active
    assert user.email is None
    # If any of these fail, which one was it?

How to fix - add assertion messages:

def test_user_creation():
    user = create_user("alice")
    assert user.name == "alice", "User name should match input"
    assert user.is_active, "New users should be active by default"
    assert user.email is None, "Email should be None when not provided"

Alternative - use single-assertion tests:

def test_user_has_correct_name():
    user = create_user("alice")
    assert user.name == "alice"

def test_new_user_is_active():
    user = create_user("alice")
    assert user.is_active

Project reference: See tests/quality/ for the 23 test smell checks enforced on this codebase.