Exemple #1
0
 def test_noneComparator(self):
     self.assertNotEqual(NoneComparator(None),
                         NoneComparator(datetime.datetime(1, 1, 1)))
     self.assertNotEqual(NoneComparator(datetime.datetime(1, 1, 1)),
                         NoneComparator(None))
     self.assertLess(NoneComparator(None),
                     NoneComparator(datetime.datetime(1, 1, 1)))
     self.assertGreater(NoneComparator(datetime.datetime(1, 1, 1)),
                        NoneComparator(None))
     self.assertLess(NoneComparator(datetime.datetime(1, 1, 1)),
                     NoneComparator(datetime.datetime(1, 1, 2)))
     self.assertEqual(NoneComparator(datetime.datetime(1, 1, 1)),
                      NoneComparator(datetime.datetime(1, 1, 1)))
     self.assertGreater(NoneComparator(datetime.datetime(1, 1, 2)),
                        NoneComparator(datetime.datetime(1, 1, 1)))
     self.assertEqual(NoneComparator(None), NoneComparator(None))
Exemple #2
0
 def test_reverseComparisonWithNone(self):
     noneInList = ["z", None, None, "q", "a", None, "v"]
     sortedList = sorted(noneInList,
                         key=lambda x: ReverseComparator(NoneComparator(x)))
     self.assertEqual(sortedList, ["z", "v", "q", "a", None, None, None])
Exemple #3
0
 def test_noneComparison(self):
     noneInList = ["z", None, None, "q", "a", None, "v"]
     sortedList = sorted(noneInList, key=lambda x: NoneComparator(x))
     self.assertEqual(sortedList, [None, None, None, "a", "q", "v", "z"])