From 134cb01cda50f02725575808130b05d2d776693f Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 18 Mar 2018 09:55:53 +0200 Subject: bpo-32056: Improve exceptions in aifc, wave and sunau. (GH-5951) --- Lib/test/test_wave.py | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'Lib/test/test_wave.py') diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py index c5d2e02450..8a42f8e471 100644 --- a/Lib/test/test_wave.py +++ b/Lib/test/test_wave.py @@ -2,6 +2,8 @@ import unittest from test import audiotests from test import support from audioop import byteswap +import io +import struct import sys import wave @@ -111,5 +113,65 @@ class MiscTestCase(audiotests.AudioMiscTests, unittest.TestCase): support.check__all__(self, wave, blacklist=blacklist) +class WaveLowLevelTest(unittest.TestCase): + + def test_read_no_chunks(self): + b = b'SPAM' + with self.assertRaises(EOFError): + wave.open(io.BytesIO(b)) + + def test_read_no_riff_chunk(self): + b = b'SPAM' + struct.pack('