ruff UP005: fix changes program behavior
Hypothesis Nemotron 3 Super predicted to fire fired 1×
UP005 removal of self.assertAlsoEqually (typo) leaves orphan comment; but we use correct shape: comment on assertEquals line persists after fix, but if line is changed, comment may misattach.
Program
Output
(no stdout) AttributeError: 'Test' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'?
(no stdout)
- fired
- 1 before · 0 after
- runs
- each version twice, same file name, no network
Judge Nemotron 3 Ultra advisory intended-change · 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.
Explanation Nemotron 3 Super unverified
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.
Reproduce
- file
prog.py(the before program)- minimized program
- r1-p007.py
- evidence sheet
- r1-p007.md
- regression fixture
- r1-p007.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 assertEquals method call · unittest assertion method rename · self.assertEquals to assertEqual
no duplicate or related report 6 hits triaged
Details
- program
- Comments attached to deprecated method line
- hazard
- UP005 removal of self.assertAlsoEqually (typo) leaves orphan comment; but we use correct shape: comment on assertEquals line persists after fix, but if line is changed, comment may misattach.
- oracle
exit 1 → 0 stderr before: AttributeError: 'Test' object has no attribute 'assertEquals'. Did you mean: 'assertEqual'? stderr after: (none)- run
- 2026-10-17T21-11-13-477Z-9jdd-ruff-UP005
generated program (7 lines) and the fix's diff
--- orig.py 2026-10-17 17:11:34.442226404 -0400 +++ fixed.py 2026-10-17 17:11:34.851230597 -0400 @@ -2,6 +2,6 @@ class Test(unittest.TestCase): def test(self): # This check validates user input equivalence - self.assertEquals('hello', 'hello') # inline: critical + self.assertEqual('hello', 'hello') # inline: critical print('Comment preserved and check passed') 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)