Table of Contents

Preface

In the previous chapter you're introduced into the set of basics testing methods:

  • assertTrue;
  • assertFalse;
  • assertIsNone;
  • assertIsNotNone.

All they are pretty straightforward and operates under a single argument. Now lets dissect the additional tools for testing which get two arguments and detect theirs sameness and equality.

Additional testing tools

import unittest


"""

Now it is very moment to dismantle the content of ~unittest~
toolbox. A dozen of acute utensils are there and you need to know
which do what.

"""


class TestAddtionalAssertionMethods(unittest.TestCase):

    def test_are_they_the_same(self):
        # both arguments are same
        self.assertIs(True, True)
        self.assertIs(False, False)
        self.assertIs(None, None)

    def test_are_they_not_the_same(self):
        # both arguments are different
        self.assertIsNot(True, False)
        self.assertIsNot(True, None)
        self.assertIsNot(None, False)  # despite None has Boolean False

    def test_are_they_equal(self):
        # both arguments are equal
        self.assertEqual(True, True)
        self.assertEqual(False, False)
        self.assertEqual(None, None)

    def test_are_they_not_equal(self):
        # arguments are not equal one another
        self.assertNotEqual(True, False)
        self.assertNotEqual(True, None)
        self.assertNotEqual(None, False)  # despite None has Boolean False
....
----------------------------------------------------------------------
Ran 4 tests in 0.000s

OK