##// END OF EJS Templates
Merge pull request #13213 from Kojoley/fix-bunch-of-doctests...
Matthias Bussonnier -
r26940:32497c8d merge
parent child
Show More
@@ -69,31 +69,33 class Audio(DisplayObject):
69 69 Generate a sound
70 70
71 71 >>> import numpy as np
72 ... framerate = 44100
73 ... t = np.linspace(0,5,framerate*5)
74 ... data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)
75 ... Audio(data, rate=framerate)
72 >>> framerate = 44100
73 >>> t = np.linspace(0,5,framerate*5)
74 >>> data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)
75 >>> Audio(data, rate=framerate)
76 <IPython.lib.display.Audio object>
76 77
77 78 Can also do stereo or more channels
78 79
79 80 >>> dataleft = np.sin(2*np.pi*220*t)
80 ... dataright = np.sin(2*np.pi*224*t)
81 ... Audio([dataleft, dataright], rate=framerate)
81 >>> dataright = np.sin(2*np.pi*224*t)
82 >>> Audio([dataleft, dataright], rate=framerate)
83 <IPython.lib.display.Audio object>
82 84
83 85 From URL:
84 86
85 >>> Audio("http://www.nch.com.au/acm/8k16bitpcm.wav")
86 >>> Audio(url="http://www.w3schools.com/html/horse.ogg")
87 >>> Audio("http://www.nch.com.au/acm/8k16bitpcm.wav") # doctest: +SKIP
88 >>> Audio(url="http://www.w3schools.com/html/horse.ogg") # doctest: +SKIP
87 89
88 90 From a File:
89 91
90 >>> Audio('/path/to/sound.wav')
91 >>> Audio(filename='/path/to/sound.ogg')
92 >>> Audio('/path/to/sound.wav') # doctest: +SKIP
93 >>> Audio(filename='/path/to/sound.ogg') # doctest: +SKIP
92 94
93 95 From Bytes:
94 96
95 >>> Audio(b'RAW_WAV_DATA..')
96 >>> Audio(data=b'RAW_WAV_DATA..')
97 >>> Audio(b'RAW_WAV_DATA..') # doctest: +SKIP
98 >>> Audio(data=b'RAW_WAV_DATA..') # doctest: +SKIP
97 99
98 100 See Also
99 101 --------
@@ -221,11 +221,9 class IPythonConsoleLexer(Lexer):
221 221 In [2]: a
222 222 Out[2]: 'foo'
223 223
224 In [3]: print a
224 In [3]: print(a)
225 225 foo
226 226
227 In [4]: 1 / 0
228
229 227
230 228 Support is also provided for IPython exceptions:
231 229
@@ -234,13 +232,9 class IPythonConsoleLexer(Lexer):
234 232 .. code-block:: ipythonconsole
235 233
236 234 In [1]: raise Exception
237
238 ---------------------------------------------------------------------------
239 Exception Traceback (most recent call last)
240 <ipython-input-1-fca2ab0ca76b> in <module>
241 ----> 1 raise Exception
242
243 Exception:
235 Traceback (most recent call last):
236 ...
237 Exception
244 238
245 239 """
246 240 name = 'IPython console session'
@@ -48,7 +48,7 def passwd(passphrase=None, algorithm='sha1'):
48 48 Examples
49 49 --------
50 50 >>> passwd('mypassword')
51 'sha1:7cf3:b7d6da294ea9592a9480c8f52e63cd42cfb9dd12'
51 'sha1:7cf3:b7d6da294ea9592a9480c8f52e63cd42cfb9dd12' # random
52 52
53 53 """
54 54 if passphrase is None:
@@ -4,6 +4,9 This file just contains doctests both using plain python and IPython prompts.
4 4 All tests should be loaded by nose.
5 5 """
6 6
7 import os
8
9
7 10 def pyfunc():
8 11 """Some pure python tests...
9 12
@@ -38,18 +41,6 def ipfunc():
38 41 0 1 1 2 2 3
39 42
40 43
41 Examples that access the operating system work:
42
43 In [1]: !echo hello
44 hello
45
46 In [2]: !echo hello > /tmp/foo_iptest
47
48 In [3]: !cat /tmp/foo_iptest
49 hello
50
51 In [4]: rm -f /tmp/foo_iptest
52
53 44 It's OK to use '_' for the last result, but do NOT try to use IPython's
54 45 numbered history of _NN outputs, since those won't exist under the
55 46 doctest environment:
@@ -72,6 +63,25 def ipfunc():
72 63 return 'ipfunc'
73 64
74 65
66 def ipos():
67 """Examples that access the operating system work:
68
69 In [1]: !echo hello
70 hello
71
72 In [2]: !echo hello > /tmp/foo_iptest
73
74 In [3]: !cat /tmp/foo_iptest
75 hello
76
77 In [4]: rm -f /tmp/foo_iptest
78 """
79 pass
80
81
82 ipos.__skip_doctest__ = os.name == "nt"
83
84
75 85 def ranfunc():
76 86 """A function with some random output.
77 87
@@ -21,7 +21,7 Another example::
21 21
22 22 Just like in IPython docstrings, you can use all IPython syntax and features::
23 23
24 In [9]: !echo "hello"
24 In [9]: !echo hello
25 25 hello
26 26
27 27 In [10]: a='hi'
@@ -11,6 +11,7 import nose.tools as nt
11 11
12 12 # Our own
13 13 from IPython.testing import decorators as dec
14 from IPython.testing.skipdoctest import skip_doctest
14 15
15 16 #-----------------------------------------------------------------------------
16 17 # Utilities
@@ -59,6 +60,7 def test_deliberately_broken2():
59 60
60 61 # Verify that we can correctly skip the doctest for a function at will, but
61 62 # that the docstring itself is NOT destroyed by the decorator.
63 @skip_doctest
62 64 def doctest_bad(x,y=1,**k):
63 65 """A function whose doctest we need to skip.
64 66
@@ -106,6 +108,7 class FooClass(object):
106 108 2
107 109 """
108 110
111 @skip_doctest
109 112 def __init__(self,x):
110 113 """Make a FooClass.
111 114
@@ -117,6 +120,7 class FooClass(object):
117 120 print('Making a FooClass.')
118 121 self.x = x
119 122
123 @skip_doctest
120 124 def bar(self,y):
121 125 """Example:
122 126
@@ -33,7 +33,7 if sys.platform == 'win32':
33 33 Examples
34 34 --------
35 35
36 >>> get_long_path_name('c:\\docume~1')
36 >>> get_long_path_name('c:\\\\docume~1')
37 37 'c:\\\\Documents and Settings'
38 38
39 39 """
General Comments 0
You need to be logged in to leave comments. Login now