Title: Theory / Unimportant / CS / Programming / Python / Lib / unittest / assertions
Tags: automatedNewLineAfterCommaSpace seen_description
On every note of this deck, unless a note says otherwise:
Page: https://docs.python.org/3/library/unittest.html

Instruction: self.assert(Not)Equal(left, right)
Effect: fail the test case if left == right / left != right
Context: class TestCaseName(unittest.TestCase):
   def test_foo(self):

Instruction: self.assertRaises(exceptionType, fun)
Effect: fail the test case if fun() do not raise exceptionType
Context: class TestCaseName(unittest.TestCase):
   def test_foo(self):

Instruction: self.assertFalse(expr)
Effect: fail the test case if expr is Falsy
Context: class TestCaseName(unittest.TestCase):
   def test_foo(self):

Instruction: self.assertTrue(expr)
Effect: fail the test case if expr is Truthy
Context: class TestCaseName(unittest.TestCase):
   def test_foo(self):

Instruction: self.assertIs(Not)(
  left,
  right
)
Effect: Test which succeed if `left is (not) right`
Language: python
Context: unittest

Instruction: self.assertIs(Not)None(expr)
Effect: Test which succeed if `expr is (not) None`
Language: python
Context: unittest

Instruction: self.assert(Not)In(
  expr,
  container
)
Effect: Test which succeed if `expr (not) in container`
Language: python
Context: unittest

Instruction: self.assertIs(Not)Instance(
  expr,
  cls
)
Effect: Test which succeed if `isinstance(expr, cls)`
Language: python
Context: unittest

Instruction: self.assertRaises(
  exceptionType,
  message,
  fun
)
Effect: Test if fun() raises an exceptionType which match with regexp message
Language: python
Context: unittest

Instruction: self.assertWarns(
  warnType,
  message,
  fun
)
Effect: Test if fun() raises a warnType which match with regexp message
Language: python
Context: unittest

Instruction: self.assertWarns(
  warnType,
  fun
)
Effect: Test if fun() raises a warnType
Language: python
Context: unittest

Instruction: self.assertLogs(
  logger,
  level
)
Effect: test that logger get a log of level level
Language: python
Context: unittest

Instruction: self.assert(Not)AlmostEqual(
  left,
  right,
  places=7
)
Effect: test that left and right are equal up to 7 decimal places
Language: python
Context: unittest

Instruction: self.assertGreater/Less(
  left,
  right
)
Effect: test that left > right, left < right
Language: python
Context: unittest

Instruction: self.assertLess/GreaterEqual(
  left,
  right
)
Effect: test that left <= right, left >= right
Language: python
Context: unittest

Instruction: self.assert(Not)Regex(
  text,
  regex
)
Effect: test that text (do not) match regex
Language: python
Context: unittest

Instruction: self.assertCountEqual(
  left,
  right
)
Effect: test that Counter of left and right are equal
Language: python
Context: unittest