mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Issue #16685: Added support for writing any bytes-like objects in the aifc,
sunau, and wave modules.
This commit is contained in:
parent
7714ebbe0e
commit
452bab4acf
8 changed files with 51 additions and 0 deletions
|
|
@ -146,6 +146,30 @@ class AudioWriteTests(AudioTests):
|
|||
|
||||
self.check_file(TESTFN, self.nframes, self.frames)
|
||||
|
||||
def test_write_bytearray(self):
|
||||
f = self.create_file(TESTFN)
|
||||
f.setnframes(self.nframes)
|
||||
f.writeframes(bytearray(self.frames))
|
||||
f.close()
|
||||
|
||||
self.check_file(TESTFN, self.nframes, self.frames)
|
||||
|
||||
def test_write_array(self):
|
||||
f = self.create_file(TESTFN)
|
||||
f.setnframes(self.nframes)
|
||||
f.writeframes(array.array('h', self.frames))
|
||||
f.close()
|
||||
|
||||
self.check_file(TESTFN, self.nframes, self.frames)
|
||||
|
||||
def test_write_memoryview(self):
|
||||
f = self.create_file(TESTFN)
|
||||
f.setnframes(self.nframes)
|
||||
f.writeframes(memoryview(self.frames))
|
||||
f.close()
|
||||
|
||||
self.check_file(TESTFN, self.nframes, self.frames)
|
||||
|
||||
def test_incompleted_write(self):
|
||||
with open(TESTFN, 'wb') as testfile:
|
||||
testfile.write(b'ababagalamaga')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue