Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5db5794

Browse files
committed
Add basic tests for display.Audio from data.
numpy is included in the test requirements; tests requiring numpy can always be run.
1 parent 708961c commit 5db5794

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

IPython/lib/tests/test_display.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222

2323
# Third-party imports
2424
import nose.tools as nt
25+
import numpy
2526

2627
# Our own imports
2728
from IPython.lib import display
28-
from IPython.testing.decorators import skipif_not_numpy
2929

3030
#-----------------------------------------------------------------------------
3131
# Classes and functions
@@ -179,11 +179,19 @@ def test_recursive_FileLinks():
179179
actual = actual.split('\n')
180180
nt.assert_equal(len(actual), 2, actual)
181181

182-
@skipif_not_numpy
183182
def test_audio_from_file():
184183
path = pjoin(dirname(__file__), 'test.wav')
185184
display.Audio(filename=path)
186185

186+
def test_audio_from_numpy_array():
187+
display.Audio(get_test_tone(), rate=44100)
188+
189+
def test_audio_from_numpy_array_without_rate_raises():
190+
nt.assert_raises(ValueError, display.Audio, get_test_tone())
191+
192+
def get_test_tone():
193+
return numpy.sin(2 * numpy.pi * 440 * numpy.linspace(0, 1, 44100))
194+
187195
def test_code_from_file():
188196
c = display.Code(filename=__file__)
189197
assert c._repr_html_().startswith('<style>')

0 commit comments

Comments
 (0)