# 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): real, severity high. The rule rewrites self.assertEquals to self.assertEqual assuming it only replaces a deprecated alias, but the program defines a custom assertEquals method in a subclass. After the fix, the call resolves to the standard assertEqual instead of the custom method, silently changing behavior from printing to doing nothing.
- Program: minimized from 10 to 8 lines

## Reproducer

```python
import unittest
class CustomTestCase(unittest.TestCase):
    def assertEquals(self, a, b):
        print('Custom assertEquals called with', a, b)
class Test(CustomTestCase):
    def test(self):
        self.assertEquals(1, 1)
Test().test()
```

## Commands

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

## Observed

```
stdout before:
Custom assertEquals called with 1 1
stdout after:
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:37:30.724125541 -0400
+++ fixed.py	2026-10-22 13:37:33.866178664 -0400
@@ -4,5 +4,5 @@
         print('Custom assertEquals called with', a, b)
 class Test(CustomTestCase):
     def test(self):
-        self.assertEquals(1, 1)
+        self.assertEqual(1, 1)
 Test().test()
```

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

The original method `assertEquals` in `CustomTestCase` overrides `unittest.TestCase`'s method to include a print statement; renaming it to `assertEqual` calls the parent class’s version instead, which performs only the assertion without printing, thus omitting the custom output and changing observable behavior.

## Upstream search

Queries: "UP005 fix", "UP005 custom assertEquals method override", "unittest assertEquals to assertEqual conversion", "ruff UP005 subclass method renaming"

- no duplicate or related report found among 5 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

</details>
