use-assert-is-not-none¶
Prefer assertIsNotNone and assertIsNone for unittest None checks.
Message¶
“assertTrue” and “assertFalse” are deprecated. Use “assertIsNotNone” and “assertIsNone” instead.
References¶
Valid examples¶
self.assertIsNotNone(x)
self.assertIsNone(x)
self.assertIsNone(None)
self.assertIsNotNone(f(x))
self.assertIsNone(f(x))
self.assertIsNone(object.key)
Show more
self.assertIsNotNone(object.key)
Invalid examples¶
self.assertTrue(a is not None)
Suggested fix
self.assertIsNotNone(a)
self.assertTrue(not x is None)
Suggested fix
self.assertIsNotNone(x)
self.assertTrue(f() is not None)
Suggested fix
self.assertIsNotNone(f())
Show more
self.assertTrue(not x is not None)
Suggested fix
self.assertIsNone(x)
self.assertTrue(f(x) is not None)
Suggested fix
self.assertIsNotNone(f(x))
self.assertTrue(x is None)
Suggested fix
self.assertIsNone(x)
self.assertFalse(x is not None)
Suggested fix
self.assertIsNone(x)
self.assertFalse(not x is None)
Suggested fix
self.assertIsNone(x)
self.assertFalse(f() is not None)
Suggested fix
self.assertIsNone(f())
self.assertFalse(not x is not None)
Suggested fix
self.assertIsNotNone(x)
self.assertFalse(f(x) is not None)
Suggested fix
self.assertIsNone(f(x))
self.assertFalse(x is None)
Suggested fix
self.assertIsNotNone(x)