Mercurial > hg > auditok
changeset 73:60854b74ee5d
Add tests for AudioSource shortcut properties
author | Amine SEHILI <amine.sehili@gmail.com> |
---|---|
date | Sun, 05 Feb 2017 12:06:04 +0100 |
parents | fc95336aeb28 |
children | b37ca4131a04 25d479e4ddb2 |
files | tests/test_audio_source.py |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_audio_source.py Sun Feb 05 12:04:38 2017 +0100 +++ b/tests/test_audio_source.py Sun Feb 05 12:06:04 2017 +0100 @@ -478,5 +478,33 @@ a_source.channels = 2 +class TestAudioSourceShortProperties(unittest.TestCase): + + def test_read_short_properties(self): + + data = "" + sampling_rate = 8000 + sample_width = 2 + channels = 1 + a_source = BufferAudioSource(data, sampling_rate, sample_width, channels) + + self.assertEqual(a_source.sr, sampling_rate) + self.assertEqual(a_source.sw, sample_width) + self.assertEqual(a_source.ch, channels) + + def test_set_readonly_short_properties_exception(self): + + data = "" + sampling_rate = 8000 + sample_width = 2 + channels = 1 + a_source = BufferAudioSource(data, sampling_rate, sample_width, channels) + + with self.assertRaises(AttributeError): + a_source.sr = 16000 + a_source.sw = 1 + a_source.ch = 2 + + if __name__ == "__main__": unittest.main()