summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_wave.py
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-08-28 17:22:16 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-08-28 17:22:16 (GMT)
commit64a38c0eb5b7fd6e4ee5f3e912cff9eda8dd19af (patch)
tree457064e7557fbfd0538aba4e2a42d8acbd6f2328 /Lib/test/test_wave.py
parenta62074883b7a32f83b13525b01efb619ae478cdf (diff)
downloadcpython-64a38c0eb5b7fd6e4ee5f3e912cff9eda8dd19af.zip
cpython-64a38c0eb5b7fd6e4ee5f3e912cff9eda8dd19af.tar.gz
cpython-64a38c0eb5b7fd6e4ee5f3e912cff9eda8dd19af.tar.bz2
Issue #1512791: In setframerate method of Wave_write, round non-integral
inputs to the nearest integer. Thanks Neil Tallim for the patch.
Diffstat (limited to 'Lib/test/test_wave.py')
-rw-r--r--Lib/test/test_wave.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py
index 1bcaa242..e0aace4 100644
--- a/Lib/test/test_wave.py
+++ b/Lib/test/test_wave.py
@@ -22,11 +22,14 @@ class TestWave(unittest.TestCase):
except OSError:
pass
- def test_it(self):
+ def test_it(self, test_rounding=False):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)
self.f.setsampwidth(sampwidth)
- self.f.setframerate(framerate)
+ if test_rounding:
+ self.f.setframerate(framerate - 0.1)
+ else:
+ self.f.setframerate(framerate)
self.f.setnframes(nframes)
output = b'\0' * nframes * nchannels * sampwidth
self.f.writeframes(output)
@@ -39,6 +42,13 @@ class TestWave(unittest.TestCase):
self.assertEqual(nframes, self.f.getnframes())
self.assertEqual(self.f.readframes(nframes), output)
+ def test_fractional_framerate(self):
+ """
+ Addresses [ 1512791 ] module wave does no rounding
+ Floating point framerates should be rounded, rather than truncated.
+ """
+ self.test_it(test_rounding=True)
+
def test_issue7681(self):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)