# ruff UP005: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: ruff ruff 0.17.1
- Rule: UP005 (tool labels the fix: unknown, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): intended-change, severity high. The rule replaces the deprecated alias assertEquals with assertEqual, which is exactly the semantic change the rule documents. The before-run fails with AttributeError because assertEquals was removed in Python 3.12, while the after-run succeeds, demonstrating the fix does what it is designed to do.
- Program: minimized from 7 to 5 lines

## Reproducer

```python
import unittest
class Test(unittest.TestCase):
    def test(self):
        self.assertEquals('hello', 'hello')  # inline: critical
Test().test()
```

## Commands

```sh
python3 prog.py
ruff check --preview --isolated --select UP005 --fix prog.py
python3 prog.py
```

## Observed

```
exit 1 → 0
stderr before: AttributeError: 'Test' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'?
stderr after: (none)
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:38:45.137384291 -0400
+++ fixed.py	2026-10-22 13:38:48.211436318 -0400
@@ -1,5 +1,5 @@
 import unittest
 class Test(unittest.TestCase):
     def test(self):
-        self.assertEquals('hello', 'hello')  # inline: critical
+        self.assertEqual('hello', 'hello')  # inline: critical
 Test().test()
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original call to `self.assertEquals` raises an `AttributeError` because that method does not exist on `unittest.TestCase`. After renaming it to `self.assertEqual`, which *does* exist, the assertion succeeds silently, changing the program’s behavior from raising an exception to completing normally—hence the shift from exit code 1 to 0. This change fixes a bug but alters observable execution flow.

## Upstream search

Queries: "UP005 fix", "UP005 assertEquals method call", "unittest assertion method rename", "self.assertEquals to assertEqual"

- no duplicate or related report found among 6 hits

<details><summary>All hits</summary>

- [github, closed] unused-function-argument not silenced by prefixed underscore if variable name is "次" — https://github.com/astral-sh/ruff/issues/28721
- [github, closed] Formatter: Bug with Pragma Comment for pyright being moved to invalid position — https://github.com/astral-sh/ruff/issues/8481
- [github, closed] Fixed code unformatted — https://github.com/astral-sh/ruff/issues/8619
- [github, closed] Add option to disable preview warnings — https://github.com/astral-sh/ruff/issues/8620
- [github, closed] Implement pyupgrade — https://github.com/astral-sh/ruff/issues/827
- [github, closed] Implement autoformat capabilities — https://github.com/astral-sh/ruff/issues/1904

</details>
