Hi
Thanks for the tool. I just used it to mass-modernize asserts across a ~250k line project.
I found a bunch of bugs on the way. Rather than spam you with loads of individual issues, I’m reporting them all here. Happy to split them if you’d prefer, but I see development isn’t ongoing, so I don’t want to burden you.
I also see that Ruff has some powers to do this rewriting now, such as from its pytest-unittest-assertion rule, so maybe this tool is less relevant now.
Anyway, here’s the list, and thanks again!
- It added a second
isinstance argument outside of parentheses:
assert isinstance(
response.context_data["inline_admin_formset"].formset
), ClickToRenderInlineFormSetBase
- Inserted a
\ before a comment, which is a SyntaxError:
assert test_count.short_description == \ # type: ignore[union-attr, attr-defined]
"test relation"
- Badly indented a comment, resulting in:
assert something == \
something2
# some comment
- The rewriting of
== True to is True didn’t work in many cases, same for False / None:
assert form["file_reviewed"].value() == True
- It incorrectly ported the
places argument to pytest.approx when not provided as a keyword argument:
self.assertAlmostEqual(x, y, 2)
assert x = pytest.approx(y), 2
- It incorrectly placed
is not None when there was a msg argument:
-self.assertIsNotNone(x, y)
+assert x, y is not None
- It incorrectly placed
not for an expression, which needed parnthesizing:
-self.assertFalse(a and b)
+assert not a and b
- It poorly rewrote this bad single-argument
assertEqual call:
def test_example(self):
with self.assertRaises(NotImplementedError):
self.assertEqual(BaseDoor().open())
(This call didn't get a chance to crash at runtime because the NotImplementedError was raised first.)
...it ended up attaching the == for the assertEqual later on in the file,.
- It inserted
\ into multiline strings, changing their contents:
-self.assertEqual(
- something,
- """
- bla
- bla
- """
-)
+assert \
+ something == \
+ """ \
+ bla \
+ bla \
+ """ \
Hi
Thanks for the tool. I just used it to mass-modernize asserts across a ~250k line project.
I found a bunch of bugs on the way. Rather than spam you with loads of individual issues, I’m reporting them all here. Happy to split them if you’d prefer, but I see development isn’t ongoing, so I don’t want to burden you.
I also see that Ruff has some powers to do this rewriting now, such as from its
pytest-unittest-assertionrule, so maybe this tool is less relevant now.Anyway, here’s the list, and thanks again!
isinstanceargument outside of parentheses:\before a comment, which is aSyntaxError:== Truetois Truedidn’t work in many cases, same forFalse/None:placesargument topytest.approxwhen not provided as a keyword argument:is not Nonewhen there was amsgargument:notfor an expression, which needed parnthesizing:assertEqualcall:(This call didn't get a chance to crash at runtime because the
NotImplementedErrorwas raised first.)...it ended up attaching the
==for theassertEquallater on in the file,.\into multiline strings, changing their contents: