Beispiel #1
0
    def test(self):
        a = matching.Match()
        a.dist = 100
        a.info_dir_change = True

        b = matching.Match()
        b.dist = 100
        b.info_dir_change = True

        self.assertEqual(a, b)
        b.info_dir_change = False
        self.assertTrue((a > b))
        self.assertTrue((b < a))

        b.dist = 200

        self.assertTrue((a < b))
        self.assertTrue((b > a))
    def test(self):
        a = matching.Match()
        a.dist = 100
        a.info_dir_change = True

        b = matching.Match()
        b.dist = 100
        b.info_dir_change = True

        self.assertEquals(a, b)
        b.info_dir_change = False
        self.assertEquals(cmp(a, b), 1)
        self.assertEquals(cmp(b, a), -1)

        b.dist = 200

        self.assertEquals(cmp(a, b), -1)
        self.assertEquals(cmp(b, a), 1)
Beispiel #3
0
    def test_append(self):
        ml = matching.MatchList()
        ml.threshold = 100

        a = matching.Match()
        a.dist = 100
        ml.append(a)
        self.assertEqual(len(ml), 1)

        a = matching.Match()
        a.dist = 200
        ml.append(a)
        self.assertEqual(len(ml), 2)
        self.assertEqual(len(ml.bastards), 1)

        ml.allow_info_dir_change = False
        a = matching.Match()
        a.dist = 0
        a.info_dir_change = True
        ml.append(a)
        self.assertEqual(len(ml), 3)
        self.assertEqual(len(ml.bastards), 2)
Beispiel #4
0
    def test_sort(self):
        ml = matching.MatchList()
        ml.threshold = 100

        a = matching.Match()
        a.dist = 100
        ml.append(a)

        b = matching.Match()
        b.dist = 5
        ml.append(b)

        c = matching.Match()
        c.dist = 0
        ml.append(c)

        l = [c, b, a]

        ml.sort()

        for x, y in zip(l, ml):
            self.assertEqual(x, y)

        self.assertEqual(ml.best(), c)