# AssertionError: assert 200 == 404
 +  where 200 = <Response [200]>.status_code

- **ID:** `python/pytest-assertion-rewrite-failure`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The test expected a 404 status code but received 200. This indicates the API endpoint returned a successful response instead of the expected error. Common causes include incorrect URL, missing authentication, or the resource actually existing when the test assumes it doesn't.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (90% success)
   ```
   Print the full URL and check if the resource exists:

print(response.url)
# Manually query the database or use curl to confirm the resource is missing before the test.
   ```
2. **** (85% success)
   ```
   Use fixtures to guarantee the resource does not exist:

@pytest.fixture
def cleanup_user():
    User.objects.filter(id=123).delete()
    yield
    User.objects.filter(id=123).delete()
   ```
3. **** (80% success)
   ```
   If the endpoint returns 200 for authorized users, adjust the test to use an unauthorized client or a different user without access.
   ```

## Dead Ends

- **** — This masks the real issue and makes the test useless for detecting regressions; the test will always pass regardless of actual behavior. (95% fail)
- **** — If the resource is immediately available, sleeping won't change the status code from 200 to 404; it just slows down tests. (80% fail)
- **** — This bypasses the real integration and may hide bugs in the actual endpoint; the test no longer validates real behavior. (75% fail)
