|
11 | 11 | from math import log, exp, pi, fsum, sin, factorial |
12 | 12 | from test import support |
13 | 13 | from fractions import Fraction |
14 | | -from collections import Counter |
| 14 | +from collections import abc, Counter |
15 | 15 |
|
16 | 16 | class TestBasicOps: |
17 | 17 | # Superclass with tests common to all generators. |
@@ -163,6 +163,22 @@ def test_sample_on_sets(self): |
163 | 163 | population = {10, 20, 30, 40, 50, 60, 70} |
164 | 164 | self.gen.sample(population, k=5) |
165 | 165 |
|
| 166 | + def test_sample_on_seqsets(self): |
| 167 | + class SeqSet(abc.Sequence, abc.Set): |
| 168 | + def __init__(self, items): |
| 169 | + self._items = items |
| 170 | + |
| 171 | + def __len__(self): |
| 172 | + return len(self._items) |
| 173 | + |
| 174 | + def __getitem__(self, index): |
| 175 | + return self._items[index] |
| 176 | + |
| 177 | + population = SeqSet([2, 4, 1, 3]) |
| 178 | + with warnings.catch_warnings(): |
| 179 | + warnings.simplefilter("error", DeprecationWarning) |
| 180 | + self.gen.sample(population, k=2) |
| 181 | + |
166 | 182 | def test_sample_with_counts(self): |
167 | 183 | sample = self.gen.sample |
168 | 184 |
|
|
0 commit comments