Avoid misusing assertTrue in tests

assertTrue is not for comparing arguments. Consider assertEqual or others instead.

The purpose of the second argument of assertTrue is not for comparing equality with the first argument. It's actually the message that should be shown if the first argument is not truthy.

Calling assertTrue with two objects and expecting them to be compared will not work.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

code-review-doctorbotsuggested changes just now
tests.py
1
+
class TestFeature(unittest.TestCase):
2
+
    def test_feature(self):
3
+
        self.assertTrue(value_one, value_two)

assertTrue is not for comparing arguments. Consider assertEqual or others instead.

Read more
Suggested changes
-
        self.assertTrue(value_one, value_two)
+
        self.assertEqual(value_one, value_two)
Commit suggestion
Update tests.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.