Skip to content

Files

Latest commit

 

History

History
28 lines (18 loc) · 713 Bytes

redundant-unittest-assert.md

File metadata and controls

28 lines (18 loc) · 713 Bytes

Pattern: Redundant unit test assert

Issue: -

Description

The first argument of assertTrue and assertFalse is a condition which should evaluate to True or False. If a constant is passed as parameter, that condition will be always True thus making the assert redundant.

Example of incorrect code:

class Tests(unittest.TestCase):
    def test_something(self):
        self.assertTrue(1)

Example of correct code:

class Tests(unittest.TestCase):
    def test_something(self):
        self.assertTrue('bar'.isupper())

Further Reading