def test1(self):
     # simple test with a known answer
     cont = TopNContainer(4)
     for foo in range(10):
         cont.Insert(foo, str(foo))
     assert cont.GetPts() == list(range(6, 10))
     assert cont.GetExtras() == [str(x) for x in range(6, 10)]
 def test_keepAll(self):
     # simple test with a known answer where we keep all
     cont = TopNContainer(-1)
     for i in range(10):
         cont.Insert(9 - i, str(9 - i))
         self.assertEqual(len(cont), i + 1)
     assert cont.GetPts() == list(range(10))
     assert cont.GetExtras() == [str(x) for x in range(10)]
 def test2(self):
     # larger scale random test
     cont = TopNContainer(50)
     for _ in range(1000):
         cont.Insert(random.random())
     vs = cont.GetPts()
     last = vs.pop(0)
     while vs:
         assert vs[0] >= last
         last = vs.pop(0)