예제 #1
0
    def test_ordered2(self):
        sel = TimeSelector(self.sleep(1, 2, 3), True)

        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert i == 2
        assert sel.best.__name__ == "1"
        assert sel.metric[-1] is None

        sel.prepend(self.sleep(2))

        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert i == 1
        assert sel.best.__name__ == "1"
        assert sel.metric[-1] is None

        sel.reset()
        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert i == 3
        assert sel.best.__name__ == "1"
        assert sel.metric[-1] is None
예제 #2
0
    def test_ordered2(self):
        sel = TimeSelector(self.sleep(1, 2, 3), True)

        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert_equal(i, 2)
        assert_equal(sel.best.__name__, "1")
        assert_equal(sel.performances[-1], None)

        sel.prepend(self.sleep(2))

        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert_equal(i, 1)
        assert_equal(sel.best.__name__, "1")
        assert_equal(sel.performances[-1], None)

        sel.reset()
        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert_equal(i, 3)
        assert_equal(sel.best.__name__, "1")
        assert_equal(sel.performances[-1], None)
예제 #3
0
    def test_selector1(self):

        sel = TimeSelector()
        sel.prepend(self.sleep(1))
        sel.prepend(self.sleep(2))
        sel.append(self.sleep(3))

        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert_equal(i, 3)
        assert_equal(sel.best.__name__, "1")
예제 #4
0
    def test_selector1(self):

        sel = TimeSelector()
        sel.prepend(self.sleep(1))
        sel.prepend(self.sleep(2))
        sel.append(self.sleep(3))
        str(sel)

        i = 0
        while sel.best is None:
            sel()
            i += 1
        assert i == 3
        assert sel.best.__name__ == "1"