magnum/HACKING.rst
Bertrand Lallau 798c7e35ef Use assertIn and assertNotIn
Tests should use:
  self.assertIn(value, list)
  self.assertNotIn(value, list)

instead of:
  self.assertTrue(value in list)
  self.assertFalse(value in list)

because assertIn and assertNotIn raise more meaningful errors:
  self.assertIn(3, [1, 2])
  >>> MismatchError: 3 not in [1, 2]

  self.assertTrue(3 in [1, 2])
  >>> AssertionError: False is not true

Closes-Bug: #1510007
Change-Id: If33252cc93c06a85e61871fb7b22b726f4a08500
2015-11-02 22:35:04 +01:00

876 B

Magnum Style Commandments

Magnum Specific Commandments

  • [M301] policy.enforce_wsgi decorator must be the first decorator on a method.
  • [M318] Change assertEqual(A, None) or assertEqual(None, A) by optimal assert like assertIsNone(A)
  • [M322] Method's default argument shouldn't be mutable.
  • [M323] Change assertEqual(True, A) or assertEqual(False, A) by optimal assert like assertTrue(A) or assertFalse(A)
  • [M302] Change assertEqual(A is not None) by optimal assert like assertIsNotNone(A).
  • [M316] Change assertTrue(isinstance(A, B)) by optimal assert like assertIsInstance(A, B).
  • [M334] Change assertTrue/False(A in/not in B, message) to the more specific assertIn/NotIn(A, B, message)