---
name: block-assertion-roulette
enabled: true
event: file
action: block
conditions:
  - field: file_path
    operator: regex_match
    pattern: tests?/.*\.py$
  - field: new_text
    operator: regex_match
    pattern: ^\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):**
```python
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:**
```python
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:**
```python
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.
