pytestify icon indicating copy to clipboard operation
pytestify copied to clipboard

Problem with replacing assertEquals() containing a bool expression

Open dex6 opened this issue 2 years ago • 0 comments

Thank you for a tool that saves me from converting 500+ asserts manually.

However, it failed on a few, one of them being: self.assertEqual(xmap.area_is_free(b, e), used == 0)

which got converted to assert xmap.area_is_free(b, e) == used == 0

but this is not an equivalent code, cause now area_is_free() result (which is False in my particular test case) is compared directly with used value (42 in my case), making the test fail instead of passing as old version did.

It should be: assert xmap.area_is_free(b, e) == (used == 0)

Note: I didn't checked, but same problem probably affects assertNotEqual method, and also applies to other operators like !=, >, <=, etc instead of just ==.

dex6 avatar Feb 05 '24 13:02 dex6