(self)
| 139 | self.assertIn(choice(NA([25, 75])), [25, 75]) |
| 140 | |
| 141 | def test_sample(self): |
| 142 | # For the entire allowable range of 0 <= k <= N, validate that |
| 143 | # the sample is of the correct length and contains only unique items |
| 144 | N = 100 |
| 145 | population = range(N) |
| 146 | for k in range(N+1): |
| 147 | s = self.gen.sample(population, k) |
| 148 | self.assertEqual(len(s), k) |
| 149 | uniq = set(s) |
| 150 | self.assertEqual(len(uniq), k) |
| 151 | self.assertTrue(uniq <= set(population)) |
| 152 | self.assertEqual(self.gen.sample([], 0), []) # test edge case N==k==0 |
| 153 | # Exception raised if size of sample exceeds that of population |
| 154 | self.assertRaises(ValueError, self.gen.sample, population, N+1) |
| 155 | self.assertRaises(ValueError, self.gen.sample, [], -1) |
| 156 | self.assertRaises(TypeError, self.gen.sample, population, 1.0) |
| 157 | |
| 158 | def test_sample_distribution(self): |
| 159 | # For the entire allowable range of 0 <= k <= N, validate that |
nothing calls this directly
no test coverage detected