Show More
@@ -6,8 +6,6 b'' | |||||
6 |
|
6 | |||
7 | from pathlib import Path |
|
7 | from pathlib import Path | |
8 |
|
8 | |||
9 | import nose.tools as nt |
|
|||
10 |
|
||||
11 | from IPython.utils.syspathcontext import prepended_to_syspath |
|
9 | from IPython.utils.syspathcontext import prepended_to_syspath | |
12 | from IPython.utils.tempdir import TemporaryDirectory |
|
10 | from IPython.utils.tempdir import TemporaryDirectory | |
13 | from IPython.lib.deepreload import reload as dreload |
|
11 | from IPython.lib.deepreload import reload as dreload | |
@@ -28,9 +26,9 b' def test_deepreload():' | |||||
28 | # Test that A is not reloaded. |
|
26 | # Test that A is not reloaded. | |
29 | obj = A.Object() |
|
27 | obj = A.Object() | |
30 | dreload(B, exclude=["A"]) |
|
28 | dreload(B, exclude=["A"]) | |
31 |
|
|
29 | assert isinstance(obj, A.Object) is True | |
32 |
|
30 | |||
33 | # Test that A is reloaded. |
|
31 | # Test that A is reloaded. | |
34 | obj = A.Object() |
|
32 | obj = A.Object() | |
35 | dreload(B) |
|
33 | dreload(B) | |
36 |
|
|
34 | assert isinstance(obj, A.Object) is False |
@@ -21,7 +21,7 b' import wave' | |||||
21 | from io import BytesIO |
|
21 | from io import BytesIO | |
22 |
|
22 | |||
23 | # Third-party imports |
|
23 | # Third-party imports | |
24 | import nose.tools as nt |
|
24 | import pytest | |
25 |
|
25 | |||
26 | try: |
|
26 | try: | |
27 | import numpy |
|
27 | import numpy | |
@@ -48,10 +48,10 b' def test_instantiation_FileLink():' | |||||
48 | fl = display.FileLink(pathlib.PurePath('example.txt')) |
|
48 | fl = display.FileLink(pathlib.PurePath('example.txt')) | |
49 |
|
49 | |||
50 | def test_warning_on_non_existent_path_FileLink(): |
|
50 | def test_warning_on_non_existent_path_FileLink(): | |
51 | """FileLink: Calling _repr_html_ on non-existent files returns a warning |
|
51 | """FileLink: Calling _repr_html_ on non-existent files returns a warning""" | |
52 | """ |
|
52 | fl = display.FileLink("example.txt") | |
53 | fl = display.FileLink('example.txt') |
|
53 | assert fl._repr_html_().startswith("Path (<tt>example.txt</tt>)") | |
54 | nt.assert_true(fl._repr_html_().startswith('Path (<tt>example.txt</tt>)')) |
|
54 | ||
55 |
|
55 | |||
56 | def test_existing_path_FileLink(): |
|
56 | def test_existing_path_FileLink(): | |
57 | """FileLink: Calling _repr_html_ functions as expected on existing filepath |
|
57 | """FileLink: Calling _repr_html_ functions as expected on existing filepath | |
@@ -77,7 +77,7 b' def test_error_on_directory_to_FileLink():' | |||||
77 | """FileLink: Raises error when passed directory |
|
77 | """FileLink: Raises error when passed directory | |
78 | """ |
|
78 | """ | |
79 | td = mkdtemp() |
|
79 | td = mkdtemp() | |
80 |
|
|
80 | pytest.raises(ValueError, display.FileLink, td) | |
81 |
|
81 | |||
82 | #-------------------------- |
|
82 | #-------------------------- | |
83 | # FileLinks tests |
|
83 | # FileLinks tests | |
@@ -89,10 +89,10 b' def test_instantiation_FileLinks():' | |||||
89 | fls = display.FileLinks('example') |
|
89 | fls = display.FileLinks('example') | |
90 |
|
90 | |||
91 | def test_warning_on_non_existent_path_FileLinks(): |
|
91 | def test_warning_on_non_existent_path_FileLinks(): | |
92 | """FileLinks: Calling _repr_html_ on non-existent files returns a warning |
|
92 | """FileLinks: Calling _repr_html_ on non-existent files returns a warning""" | |
93 | """ |
|
93 | fls = display.FileLinks("example") | |
94 | fls = display.FileLinks('example') |
|
94 | assert fls._repr_html_().startswith("Path (<tt>example</tt>)") | |
95 | nt.assert_true(fls._repr_html_().startswith('Path (<tt>example</tt>)')) |
|
95 | ||
96 |
|
96 | |||
97 | def test_existing_path_FileLinks(): |
|
97 | def test_existing_path_FileLinks(): | |
98 | """FileLinks: Calling _repr_html_ functions as expected on existing dir |
|
98 | """FileLinks: Calling _repr_html_ functions as expected on existing dir | |
@@ -172,7 +172,8 b' def test_error_on_file_to_FileLinks():' | |||||
172 | """ |
|
172 | """ | |
173 | td = mkdtemp() |
|
173 | td = mkdtemp() | |
174 | tf1 = NamedTemporaryFile(dir=td) |
|
174 | tf1 = NamedTemporaryFile(dir=td) | |
175 |
|
|
175 | pytest.raises(ValueError, display.FileLinks, tf1.name) | |
|
176 | ||||
176 |
|
177 | |||
177 | def test_recursive_FileLinks(): |
|
178 | def test_recursive_FileLinks(): | |
178 | """FileLinks: Does not recurse when recursive=False |
|
179 | """FileLinks: Does not recurse when recursive=False | |
@@ -210,7 +211,7 b' class TestAudioDataWithNumpy(TestCase):' | |||||
210 |
|
211 | |||
211 | @skipif_not_numpy |
|
212 | @skipif_not_numpy | |
212 | def test_audio_from_numpy_array_without_rate_raises(self): |
|
213 | def test_audio_from_numpy_array_without_rate_raises(self): | |
213 |
|
|
214 | self.assertRaises(ValueError, display.Audio, get_test_tone()) | |
214 |
|
215 | |||
215 | @skipif_not_numpy |
|
216 | @skipif_not_numpy | |
216 | def test_audio_data_normalization(self): |
|
217 | def test_audio_data_normalization(self): | |
@@ -232,10 +233,10 b' class TestAudioDataWithNumpy(TestCase):' | |||||
232 | assert actual_max_value == expected_max_value |
|
233 | assert actual_max_value == expected_max_value | |
233 |
|
234 | |||
234 | def test_audio_data_without_normalization_raises_for_invalid_data(self): |
|
235 | def test_audio_data_without_normalization_raises_for_invalid_data(self): | |
235 |
|
|
236 | self.assertRaises( | |
236 | ValueError, |
|
237 | ValueError, | |
237 | lambda: display.Audio([1.001], rate=44100, normalize=False)) |
|
238 | lambda: display.Audio([1.001], rate=44100, normalize=False)) | |
238 |
|
|
239 | self.assertRaises( | |
239 | ValueError, |
|
240 | ValueError, | |
240 | lambda: display.Audio([-1.001], rate=44100, normalize=False)) |
|
241 | lambda: display.Audio([-1.001], rate=44100, normalize=False)) | |
241 |
|
242 | |||
@@ -253,9 +254,8 b' class TestAudioDataWithoutNumpy(TestAudioDataWithNumpy):' | |||||
253 | @skipif_not_numpy |
|
254 | @skipif_not_numpy | |
254 | def test_audio_raises_for_nested_list(self): |
|
255 | def test_audio_raises_for_nested_list(self): | |
255 | stereo_signal = [list(get_test_tone())] * 2 |
|
256 | stereo_signal = [list(get_test_tone())] * 2 | |
256 | nt.assert_raises( |
|
257 | self.assertRaises(TypeError, lambda: display.Audio(stereo_signal, rate=44100)) | |
257 | TypeError, |
|
258 | ||
258 | lambda: display.Audio(stereo_signal, rate=44100)) |
|
|||
259 |
|
259 | |||
260 | @skipif_not_numpy |
|
260 | @skipif_not_numpy | |
261 | def get_test_tone(scale=1): |
|
261 | def get_test_tone(scale=1): |
General Comments 0
You need to be logged in to leave comments.
Login now