mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 19:34:08 +00:00 
			
		
		
		
	Issue #18919: Fixed resource leaks in audio tests.
This commit is contained in:
		
							parent
							
								
									4606d36d7f
								
							
						
					
					
						commit
						85812bca21
					
				
					 1 changed files with 12 additions and 12 deletions
				
			
		| 
						 | 
					@ -141,18 +141,18 @@ class AudioTestsWithSourceFile(AudioTests):
 | 
				
			||||||
                          self.sndfilenframes, self.comptype, self.compname)
 | 
					                          self.sndfilenframes, self.comptype, self.compname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_close(self):
 | 
					    def test_close(self):
 | 
				
			||||||
        testfile = open(self.sndfilepath, 'rb')
 | 
					        with open(self.sndfilepath, 'rb') as testfile:
 | 
				
			||||||
        f = self.f = self.module.open(testfile)
 | 
					            f = self.f = self.module.open(testfile)
 | 
				
			||||||
        self.assertFalse(testfile.closed)
 | 
					            self.assertFalse(testfile.closed)
 | 
				
			||||||
        f.close()
 | 
					            f.close()
 | 
				
			||||||
        self.assertEqual(testfile.closed, self.close_fd)
 | 
					            self.assertEqual(testfile.closed, self.close_fd)
 | 
				
			||||||
        testfile = open(TESTFN, 'wb')
 | 
					        with open(TESTFN, 'wb') as testfile:
 | 
				
			||||||
        fout = self.module.open(testfile, 'wb')
 | 
					            fout = self.fout = self.module.open(testfile, 'wb')
 | 
				
			||||||
        self.assertFalse(testfile.closed)
 | 
					            self.assertFalse(testfile.closed)
 | 
				
			||||||
        with self.assertRaises(self.module.Error):
 | 
					            with self.assertRaises(self.module.Error):
 | 
				
			||||||
            fout.close()
 | 
					                fout.close()
 | 
				
			||||||
        self.assertEqual(testfile.closed, self.close_fd)
 | 
					            self.assertEqual(testfile.closed, self.close_fd)
 | 
				
			||||||
        fout.close() # do nothing
 | 
					            fout.close() # do nothing
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_read(self):
 | 
					    def test_read(self):
 | 
				
			||||||
        framesize = self.nchannels * self.sampwidth
 | 
					        framesize = self.nchannels * self.sampwidth
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue