data structures: None: testsΒΆ
the code in tests/test_none.py from None
1import unittest
2
3
4class TestNone(unittest.TestCase):
5
6 def test_what_is_none(self):
7 self.assertIsNone(None)
8
9 def test_is_none_a_boolean(self):
10 self.assertIsNotNone(False)
11 self.assertIsNotNone(True)
12 self.assertIsInstance(False, bool)
13 self.assertIsInstance(True, bool)
14 self.assertNotIsInstance(None, bool)
15
16 def test_is_none_an_integer(self):
17 self.assertIsNotNone(-1)
18 self.assertIsNotNone(0)
19 self.assertIsNotNone(1)
20 self.assertIsInstance(-1, int)
21 self.assertIsInstance(0, int)
22 self.assertIsInstance(1, int)
23 self.assertNotIsInstance(None, int)
24
25 def test_is_none_a_float(self):
26 self.assertIsNotNone(-0.1)
27 self.assertIsNotNone(0.0)
28 self.assertIsNotNone(0.1)
29 self.assertIsInstance(-0.1, float)
30 self.assertIsInstance(0.0, float)
31 self.assertIsInstance(0.1, float)
32 self.assertNotIsInstance(None, float)
33
34 def test_is_none_a_string(self):
35 self.assertIsNotNone('')
36 self.assertIsNotNone("text")
37 self.assertIsInstance('', str)
38 self.assertIsInstance("text", str)
39 self.assertNotIsInstance(None, str)
40
41 def test_is_none_a_tuple(self):
42 self.assertIsNotNone(())
43 self.assertIsNotNone((1, 2, 3, 'n'))
44 self.assertIsInstance((), tuple)
45 self.assertIsInstance((1, 2, 3, 'n'), tuple)
46 self.assertNotIsInstance(None, tuple)
47
48 def test_is_none_a_list(self):
49 self.assertIsNotNone([])
50 self.assertIsNotNone([1, 2, 3, 'n'])
51 self.assertIsInstance([], list)
52 self.assertIsInstance([1, 2, 3, 'n'], list)
53 self.assertNotIsInstance(None, list)
54
55 def test_is_none_a_set(self):
56 self.assertIsNotNone(set())
57 self.assertIsNotNone({1, 2, 3, 'n'})
58 self.assertIsInstance({1, 2, 3, 'n'}, set)
59 self.assertNotIsInstance(None, set)
60
61 def test_is_none_a_dictionary(self):
62 self.assertIsNotNone(dict())
63 self.assertIsNotNone({'key': 'value'})
64 self.assertIsInstance({}, dict)
65 self.assertIsInstance({'key': 'value'}, dict)
66 self.assertNotIsInstance(None, dict)
67
68
69# NOTES
70# None is NOT a dictionary
71# None is NOT a set
72# None is NOT a list
73# None is NOT a tuple
74# None is NOT a string
75# None is NOT a float
76# None is NOT an integer
77# None is NOT a boolean
78# None is None
79
80
81# Exceptions Encountered
82# AssertionError