This commit was manufactured by cvs2svn to create tag 'r211c1'.
[python/dscho.git] / Lib / test / output / test_doctest
blob5e54c4aaabe831f2c0145f2ac61b12c1b519bf54
1 test_doctest
2 Running doctest.__doc__
3 Trying: [1, 2, 3].remove(42)
4 Expecting:
5 Traceback (most recent call last):
6   File "<stdin>", line 1, in ?
7 ValueError: list.remove(x): x not in list
8 ok
9 Trying: x = 12
10 Expecting: nothing
12 Trying: x
13 Expecting: 12
15 Trying:
16 if x == 13:
17     print "yes"
18 else:
19     print "no"
20     print "NO"
21     print "NO!!!"
22 Expecting:
25 NO!!!
27 Trying:
28 if "yes" == \
29     "y" +   \
30     "es":   # in the source code you'll see the doubled backslashes
31     print 'yes'
32 Expecting: yes
34 Trying: assert "Easy!"
35 Expecting: nothing
37 Trying: import math
38 Expecting: nothing
40 Trying: math.floor(1.9)
41 Expecting: 1.0
43 0 of 8 examples failed in doctest.__doc__
44 Running doctest.Tester.__doc__
45 Trying: from doctest import Tester
46 Expecting: nothing
48 Trying: t = Tester(globs={'x': 42}, verbose=0)
49 Expecting: nothing
51 Trying:
52 t.runstring(r'''
53      >>> x = x * 2
54      >>> print x
55      42
56 ''', 'XYZ')
57 Expecting:
58 *****************************************************************
59 Failure in example: print x
60 from line #2 of XYZ
61 Expected: 42
62 Got: 84
63 (1, 2)
65 Trying: t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2')
66 Expecting: (0, 2)
68 Trying: t.summarize()
69 Expecting:
70 *****************************************************************
71 1 items had failures:
72    1 of   2 in XYZ
73 ***Test Failed*** 1 failures.
74 (1, 4)
76 Trying: t.summarize(verbose=1)
77 Expecting:
78 1 items passed all tests:
79    2 tests in example2
80 *****************************************************************
81 1 items had failures:
82    1 of   2 in XYZ
83 4 tests in 2 items.
84 3 passed and 1 failed.
85 ***Test Failed*** 1 failures.
86 (1, 4)
88 0 of 6 examples failed in doctest.Tester.__doc__
89 Running doctest.Tester.__init__.__doc__
90 0 of 0 examples failed in doctest.Tester.__init__.__doc__
91 Running doctest.Tester.merge.__doc__
92 Trying: from doctest import Tester
93 Expecting: nothing
95 Trying: t1 = Tester(globs={}, verbose=0)
96 Expecting: nothing
98 Trying:
99 t1.runstring('''
100 >>> x = 12
101 >>> print x
103 ''', "t1example")
104 Expecting: (0, 2)
106 Trying: t2 = Tester(globs={}, verbose=0)
107 Expecting: nothing
109 Trying:
110 t2.runstring('''
111 >>> x = 13
112 >>> print x
114 ''', "t2example")
115 Expecting: (0, 2)
117 Trying: common = ">>> assert 1 + 2 == 3\n"
118 Expecting: nothing
120 Trying: t1.runstring(common, "common")
121 Expecting: (0, 1)
123 Trying: t2.runstring(common, "common")
124 Expecting: (0, 1)
126 Trying: t1.merge(t2)
127 Expecting: *** Tester.merge: 'common' in both testers; summing outcomes.
129 Trying: t1.summarize(1)
130 Expecting:
131 3 items passed all tests:
132    2 tests in common
133    2 tests in t1example
134    2 tests in t2example
135 6 tests in 3 items.
136 6 passed and 0 failed.
137 Test passed.
138 (0, 6)
140 0 of 10 examples failed in doctest.Tester.merge.__doc__
141 Running doctest.Tester.run__test__.__doc__
142 0 of 0 examples failed in doctest.Tester.run__test__.__doc__
143 Running doctest.Tester.rundict.__doc__
144 Trying:
145 def _f():
146    '''>>> assert 1 == 1
147    '''
148 Expecting: nothing
150 Trying:
151 def g():
152    '''>>> assert 2 != 1
153    '''
154 Expecting: nothing
156 Trying: d = {"_f": _f, "g": g}
157 Expecting: nothing
159 Trying: t = Tester(globs={}, verbose=0)
160 Expecting: nothing
162 Trying: t.rundict(d, "rundict_test")  # _f is skipped
163 Expecting: (0, 1)
165 Trying: t = Tester(globs={}, verbose=0, isprivate=lambda x,y: 0)
166 Expecting: nothing
168 Trying: t.rundict(d, "rundict_test_pvt")  # both are searched
169 Expecting: (0, 2)
171 0 of 7 examples failed in doctest.Tester.rundict.__doc__
172 Running doctest.Tester.rundoc.__doc__
173 Trying: t = Tester(globs={}, verbose=0)
174 Expecting: nothing
176 Trying:
177 def _f():
178     '''Trivial docstring example.
179     >>> assert 2 == 2
180     '''
181     return 32
182 Expecting: nothing
184 Trying: t.rundoc(_f)  # expect 0 failures in 1 example
185 Expecting: (0, 1)
187 0 of 3 examples failed in doctest.Tester.rundoc.__doc__
188 Running doctest.Tester.runstring.__doc__
189 Trying: t = Tester(globs={}, verbose=1)
190 Expecting: nothing
192 Trying:
193 test = r'''
194    # just an example
195    >>> x = 1 + 2
196    >>> x
197    3
199 Expecting: nothing
201 Trying: t.runstring(test, "Example")
202 Expecting:
203 Running string Example
204 Trying: x = 1 + 2
205 Expecting: nothing
207 Trying: x
208 Expecting: 3
210 0 of 2 examples failed in string Example
211 (0, 2)
213 0 of 3 examples failed in doctest.Tester.runstring.__doc__
214 Running doctest.Tester.summarize.__doc__
215 0 of 0 examples failed in doctest.Tester.summarize.__doc__
216 Running doctest.is_private.__doc__
217 Trying: is_private("a.b", "my_func")
218 Expecting: 0
220 Trying: is_private("____", "_my_func")
221 Expecting: 1
223 Trying: is_private("someclass", "__init__")
224 Expecting: 0
226 Trying: is_private("sometypo", "__init_")
227 Expecting: 1
229 Trying: is_private("x.y.z", "_")
230 Expecting: 1
232 Trying: is_private("_x.y.z", "__")
233 Expecting: 0
235 Trying: is_private("", "")  # senseless but consistent
236 Expecting: 0
238 0 of 7 examples failed in doctest.is_private.__doc__
239 Running doctest.run_docstring_examples.__doc__
240 0 of 0 examples failed in doctest.run_docstring_examples.__doc__
241 Running doctest.testmod.__doc__
242 0 of 0 examples failed in doctest.testmod.__doc__
243 Running doctest.__test__._TestClass.__doc__
244 Trying: _TestClass(13).get() + _TestClass(-12).get()
245 Expecting: 1
247 Trying: hex(_TestClass(13).square().get())
248 Expecting: '0xa9'
250 0 of 2 examples failed in doctest.__test__._TestClass.__doc__
251 Running doctest.__test__._TestClass.__init__.__doc__
252 Trying: t = _TestClass(123)
253 Expecting: nothing
255 Trying: print t.get()
256 Expecting: 123
258 0 of 2 examples failed in doctest.__test__._TestClass.__init__.__doc__
259 Running doctest.__test__._TestClass.get.__doc__
260 Trying: x = _TestClass(-42)
261 Expecting: nothing
263 Trying: print x.get()
264 Expecting: -42
266 0 of 2 examples failed in doctest.__test__._TestClass.get.__doc__
267 Running doctest.__test__._TestClass.square.__doc__
268 Trying: _TestClass(13).square().get()
269 Expecting: 169
271 0 of 1 examples failed in doctest.__test__._TestClass.square.__doc__
272 Running string doctest.__test__.string
273 Trying: x = 1; y = 2
274 Expecting: nothing
276 Trying: x + y, x * y
277 Expecting: (3, 2)
279 0 of 2 examples failed in string doctest.__test__.string
280 5 items had no tests:
281     doctest.Tester.__init__
282     doctest.Tester.run__test__
283     doctest.Tester.summarize
284     doctest.run_docstring_examples
285     doctest.testmod
286 12 items passed all tests:
287    8 tests in doctest
288    6 tests in doctest.Tester
289   10 tests in doctest.Tester.merge
290    7 tests in doctest.Tester.rundict
291    3 tests in doctest.Tester.rundoc
292    3 tests in doctest.Tester.runstring
293    2 tests in doctest.__test__._TestClass
294    2 tests in doctest.__test__._TestClass.__init__
295    2 tests in doctest.__test__._TestClass.get
296    1 tests in doctest.__test__._TestClass.square
297    2 tests in doctest.__test__.string
298    7 tests in doctest.is_private
299 53 tests in 17 items.
300 53 passed and 0 failed.
301 Test passed.