ruff UP005: fix changes program behavior
Hypothesis Nemotron 3 Super predicted to fire fired 1×
UP005 rewrites self.assertEquals to self.assertEqual, bypassing a deliberate override in a subclass that defines assertEquals for custom behavior.
Program
Output
Custom assertEquals called with 1 1
(no stdout)
- fired
- 1 before · 0 after
- runs
- each version twice, same file name, no network
Judge Nemotron 3 Ultra advisory real · 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.
Explanation Nemotron 3 Super unverified
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.
Reproduce
- file
prog.py(the before program)- minimized program
- r1-p004.py
- evidence sheet
- r1-p004.md
- regression fixture
- r1-p004.py the minimized program with a header stating the observed change, for the tool's test suite
python3 prog.py ruff check --preview --isolated --select UP005 --fix prog.py python3 prog.py
Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra
UP005 fix · UP005 custom assertEquals method override · unittest assertEquals to assertEqual conversion · ruff UP005 subclass method renaming
no duplicate or related report 5 hits triaged
Details
- program
- Custom subclass shadowing deprecated alias intentionally
- hazard
- UP005 rewrites self.assertEquals to self.assertEqual, bypassing a deliberate override in a subclass that defines assertEquals for custom behavior.
- oracle
stdout before: Custom assertEquals called with 1 1 stdout after:- run
- 2026-10-17T21-11-13-477Z-9jdd-ruff-UP005
generated program (10 lines) and the fix's diff
--- orig.py 2026-10-17 17:11:33.054212171 -0400 +++ fixed.py 2026-10-17 17:11:33.289214581 -0400 @@ -5,6 +5,6 @@ return super().assertEqual(a, b) class Test(CustomTestCase): def test(self): - self.assertEquals(1, 1) + self.assertEqual(1, 1) self.assertEqual(2, 2) Test().test()
rule documentation given to the models
# deprecated-unittest-alias (UP005)
Derived from the **pyupgrade** linter.
Fix is always available.
## What it does
Checks for uses of deprecated methods from the `unittest` module.
## Why is this bad?
The `unittest` module has deprecated aliases for some of its methods.
The deprecated aliases were removed in Python 3.12. Instead of aliases,
use their non-deprecated counterparts.
## Example
```python
from unittest import TestCase
class SomeTest(TestCase):
def test_something(self):
self.assertEquals(1, 1)
```
Use instead:
```python
from unittest import TestCase
class SomeTest(TestCase):
def test_something(self):
self.assertEqual(1, 1)
```
## References
- [Python 3.11 documentation: Deprecated aliases](https://docs.python.org/3.11/library/unittest.html#deprecated-aliases)