Example #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
Example #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)