data structures: booleans: testsΒΆ

the code in booleans/tests/test_booleans.py from booleans

 1import unittest
 2
 3
 4class TestBooleans(unittest.TestCase):
 5
 6    def test_what_is_false(self):
 7        self.assertIsInstance(False, bool)
 8        self.assertFalse(False)
 9        self.assertFalse(None)
10        self.assertFalse(0)
11        self.assertFalse(0.0)
12        self.assertFalse(str())
13        self.assertFalse(tuple())
14        self.assertFalse(list())
15        self.assertFalse(set())
16        self.assertFalse(dict())
17
18    def test_what_is_true(self):
19        self.assertIsInstance(True, bool)
20        self.assertTrue(True)
21        self.assertTrue(-1)
22        self.assertTrue(1)
23        self.assertTrue(-0.1)
24        self.assertTrue(0.1)
25        self.assertTrue('text')
26        self.assertTrue((1, 2, 3, 'n'))
27        self.assertTrue([1, 2, 3, 'n'])
28        self.assertTrue({1, 2, 3, 'n'})
29        self.assertTrue({'key': 'value'})
30
31
32# NOTES
33# a dictionary with things is true
34# a set with things is true
35# a list with things is true
36# a tuple with things is true
37# a string with things is true
38# positive and negative numbers are true
39# True is true
40# True is not false
41# True is a boolean
42# the empty dictionary is false
43# the empty set is false
44# the empty list is false
45# the empty tuple is false
46# the empty string is false
47# 0 is false
48# None is false
49# False is false
50# False is not true
51# False is a boolean
52
53
54# Exceptions Encountered
55# AssertionError