bpo-29110: Fix file object leak in `aifc.open`. by Uberi · Pull Request #162 · python/cpython

@@ -1,4 +1,4 @@ from test.support import findfile, TESTFN, unlink from test.support import check_no_resource_warning, findfile, TESTFN, unlink

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap at 79 columns

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be 77 characters over here. Is there something I'm missing?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, I'm sorry. no problem.

import unittest from test import audiotests from audioop import byteswap Expand Down Expand Up @@ -149,6 +149,14 @@ def test_skipunknown(self): #This file contains chunk types aifc doesn't recognize. self.f = aifc.open(findfile('Sine-1000Hz-300ms.aif'))
def test_close_opened_files_on_error(self):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test tests only Aifc_read. Needed a test for Aifc_write.

Is it possible to make tests common for aifc, sunau and wave?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#293 adds test for Aifc_write.

Since this type of test is depending on implementation (raise Exception on Edge case),
I didn't tried to make this generic.

non_aifc_file = findfile('pluck-pcm8.wav', subdir='audiodata') with check_no_resource_warning(self): with self.assertRaises(aifc.Error): # Try opening a non-AIFC file, with the expectation that # `aifc.open` will fail (without raising a ResourceWarning) f = self.f = aifc.open(non_aifc_file, 'rb')
def test_params_added(self): f = self.f = aifc.open(TESTFN, 'wb') f.aiff() Expand Down