assertTrue or assertFalse tests a comparison that a specific assertion would report better

tx0/python:vague-test-assertionstrictnotestyle

What it finds

self.assertTrue(a == b) fails with "False is not true" and hides both values; self.assertEqual(a, b) shows them. The same holds for in, is, is None and isinstance, which have assertIn, assertIs, assertIsNone, assertIsInstance and their negations, and for assertEqual(x, None) and assertEqual(x, True).

From the rule's source, vague_test_assertion.rs.

Example from the rule's tests
import unittest class TestThings(unittest.TestCase):    def test_it(self):        self.assertTrue(a == b)tx0 reports: assertEqual reports both values where assertTrue does not        self.assertFalse(x in items)tx0 reports: assertNotIn reports both values        self.assertTrue(x is None)tx0 reports: assertIsNone reports both values        self.assertTrue(isinstance(x, int))tx0 reports: assertIsInstance reports both values        self.assertEqual(x, None)tx0 reports: assertIsNone reports both values where assertEqual does not        self.assertTrue(x)        self.assertEqual(a, b)
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:vague-test-assertion" = "note"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:vague-test-assertion] reason="..."

tx0 explain tx0/python:vague-test-assertion shows the same in the terminal. Found a false positive? Report it.