mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 23:21:29 +00:00 
			
		
		
		
	bpo-40325: Deprecate set object support in random.sample() (GH-19591)
This commit is contained in:
		
							parent
							
								
									482259d0dc
								
							
						
					
					
						commit
						4fe002045f
					
				
					 4 changed files with 17 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -147,7 +147,6 @@ def test_sample_distribution(self):
 | 
			
		|||
 | 
			
		||||
    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 @@ def test_sample_inputs(self):
 | 
			
		|||
    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']
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue