diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2020-04-19 07:36:42 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 07:36:42 (GMT) |
commit | 4fe002045fcf40823154b709fef0948b2bc5e934 (patch) | |
tree | ea9d2c899b682f91fd21f50c13bfae8903f58f11 /Lib/test | |
parent | 482259d0dcf27714a84cf56b93977320bea7e093 (diff) | |
download | cpython-4fe002045fcf40823154b709fef0948b2bc5e934.zip cpython-4fe002045fcf40823154b709fef0948b2bc5e934.tar.gz cpython-4fe002045fcf40823154b709fef0948b2bc5e934.tar.bz2 |
bpo-40325: Deprecate set object support in random.sample() (GH-19591)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_random.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py index 50d4e94..42c68dd 100644 --- a/Lib/test/test_random.py +++ b/Lib/test/test_random.py @@ -147,7 +147,6 @@ class TestBasicOps: def test_sample_inputs(self): # SF bug #801342 -- population can be any iterable defining __len__() - self.gen.sample(set(range(20)), 2) self.gen.sample(range(20), 2) self.gen.sample(range(20), 2) self.gen.sample(str('abcdefghijklmnopqrst'), 2) @@ -156,6 +155,11 @@ class TestBasicOps: def test_sample_on_dicts(self): self.assertRaises(TypeError, self.gen.sample, dict.fromkeys('abcdef'), 2) + def test_sample_on_sets(self): + with self.assertWarns(DeprecationWarning): + population = {10, 20, 30, 40, 50, 60, 70} + self.gen.sample(population, k=5) + def test_choices(self): choices = self.gen.choices data = ['red', 'green', 'blue', 'yellow'] |