def test_k(self):
     for k in range(100):
         ss = StreamSampler(k)
         for i in range(5 * k):
             ss.append(i)
         self.assertEqual(len(ss), k)
 def test_small_2(self):
     ss = StreamSampler(5)
     ss.append_all(range(5))
     self.assertEqual(list(ss), list(range(5)))
 def test_rand_preserved(self):
     ss = StreamSampler(5)
     for i in range(1000): ss.append(i)
     self.assertEqual(list(ss), sorted(self.ans))
 def test_small(self):
     ss = StreamSampler(5)
     for i in range(5): ss.append(i)
     self.assertEqual(list(ss), list(range(5)))
 def test_rand(self):
     ss = StreamSampler(5, preserve=False)
     for i in range(1000): ss.append(i)
     self.assertEqual(list(ss), self.ans)