##// END OF EJS Templates
Update test_ipdoctest.py
Matthias Bussonnier -
Show More
@@ -1,77 +1,76 b''
1 1 """Tests for the ipdoctest machinery itself.
2 2
3 3 Note: in a file named test_X, functions whose only test is their docstring (as
4 4 a doctest) and which have no test functionality of their own, should be called
5 5 'doctest_foo' instead of 'test_foo', otherwise they get double-counted (the
6 6 empty function call is counted as a test, which just inflates tests numbers
7 7 artificially).
8 8 """
9 from IPython.utils.py3compat import doctest_refactor_print
10 9
11 10 def doctest_simple():
12 11 """ipdoctest must handle simple inputs
13 12
14 13 In [1]: 1
15 14 Out[1]: 1
16 15
17 16 In [2]: print(1)
18 17 1
19 18 """
20 19
21 20 def doctest_multiline1():
22 21 """The ipdoctest machinery must handle multiline examples gracefully.
23 22
24 23 In [2]: for i in range(4):
25 24 ...: print(i)
26 25 ...:
27 26 0
28 27 1
29 28 2
30 29 3
31 30 """
32 31
33 32 def doctest_multiline2():
34 33 """Multiline examples that define functions and print output.
35 34
36 35 In [7]: def f(x):
37 36 ...: return x+1
38 37 ...:
39 38
40 39 In [8]: f(1)
41 40 Out[8]: 2
42 41
43 42 In [9]: def g(x):
44 43 ...: print('x is:',x)
45 44 ...:
46 45
47 46 In [10]: g(1)
48 47 x is: 1
49 48
50 49 In [11]: g('hello')
51 50 x is: hello
52 51 """
53 52
54 53
55 54 def doctest_multiline3():
56 55 """Multiline examples with blank lines.
57 56
58 57 In [12]: def h(x):
59 58 ....: if x>1:
60 59 ....: return x**2
61 60 ....: # To leave a blank line in the input, you must mark it
62 61 ....: # with a comment character:
63 62 ....: #
64 63 ....: # otherwise the doctest parser gets confused.
65 64 ....: else:
66 65 ....: return -1
67 66 ....:
68 67
69 68 In [13]: h(5)
70 69 Out[13]: 25
71 70
72 71 In [14]: h(1)
73 72 Out[14]: -1
74 73
75 74 In [15]: h(0)
76 75 Out[15]: -1
77 76 """
General Comments 0
You need to be logged in to leave comments. Login now