Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / doctest-Example.html
CommitLineData
86530b38
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="doctest-DocTestFinder.html" />
13<link rel="prev" href="doctest-DocTest.html" />
14<link rel="parent" href="doctest-advanced-api.html" />
15<link rel="next" href="doctest-DocTestFinder.html" />
16<meta name='aesop' content='information' />
17<title>5.2.6.2 Example Objects</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="5.2.6.1 DocTest Objects"
25 href="doctest-DocTest.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="5.2.6 Advanced API"
28 href="doctest-advanced-api.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="5.2.6.3 DocTestFinder objects"
31 href="doctest-DocTestFinder.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="doctest-DocTest.html">5.2.6.1 DocTest Objects</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="doctest-advanced-api.html">5.2.6 Advanced API</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="doctest-DocTestFinder.html">5.2.6.3 DocTestFinder objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H3><A NAME="SECTION007262000000000000000"></A><A NAME="doctest-Example"></A>
56<BR>
575.2.6.2 Example Objects
58</H3>
59<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
60 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-1087' xml:id='l2h-1087' class="class">Example</tt></b>(</nobr></td>
61 <td><var>source, want</var><big>[</big><var>,
62 exc_msg</var><big>]</big><var></var><big>[</big><var>, lineno</var><big>]</big><var></var><big>[</big><var>,
63 indent</var><big>]</big><var></var><big>[</big><var>, options</var><big>]</big><var></var>)</td></tr></table></dt>
64<dd>
65 A single interactive example, consisting of a Python statement and
66 its expected output. The constructor arguments are used to
67 initialize the member variables of the same names.
68
69<span class="versionnote">New in version 2.4.</span>
70
71</dl>
72
73<P>
74<tt class="class">Example</tt> defines the following member variables. They are
75initialized by the constructor, and should not be modified directly.
76
77<P>
78<dl><dt><b><tt id='l2h-1088' xml:id='l2h-1088' class="member">source</tt></b></dt>
79<dd>
80 A string containing the example's source code. This source code
81 consists of a single Python statement, and always ends with a
82 newline; the constructor adds a newline when necessary.
83</dl>
84
85<P>
86<dl><dt><b><tt id='l2h-1089' xml:id='l2h-1089' class="member">want</tt></b></dt>
87<dd>
88 The expected output from running the example's source code (either
89 from stdout, or a traceback in case of exception). <tt class="member">want</tt>
90 ends with a newline unless no output is expected, in which case
91 it's an empty string. The constructor adds a newline when
92 necessary.
93</dl>
94
95<P>
96<dl><dt><b><tt id='l2h-1090' xml:id='l2h-1090' class="member">exc_msg</tt></b></dt>
97<dd>
98 The exception message generated by the example, if the example is
99 expected to generate an exception; or <code>None</code> if it is not
100 expected to generate an exception. This exception message is
101 compared against the return value of
102 <tt class="function">traceback.format_exception_only()</tt>. <tt class="member">exc_msg</tt>
103 ends with a newline unless it's <code>None</code>. The constructor adds
104 a newline if needed.
105</dl>
106
107<P>
108<dl><dt><b><tt id='l2h-1091' xml:id='l2h-1091' class="member">lineno</tt></b></dt>
109<dd>
110 The line number within the string containing this example where
111 the example begins. This line number is zero-based with respect
112 to the beginning of the containing string.
113</dl>
114
115<P>
116<dl><dt><b><tt id='l2h-1092' xml:id='l2h-1092' class="member">indent</tt></b></dt>
117<dd>
118 The example's indentation in the containing string, i.e., the
119 number of space characters that precede the example's first
120 prompt.
121</dl>
122
123<P>
124<dl><dt><b><tt id='l2h-1093' xml:id='l2h-1093' class="member">options</tt></b></dt>
125<dd>
126 A dictionary mapping from option flags to <code>True</code> or
127 <code>False</code>, which is used to override default options for this
128 example. Any option flags not contained in this dictionary are
129 left at their default value (as specified by the
130 <tt class="class">DocTestRunner</tt>'s <tt class="member">optionflags</tt>).
131 By default, no options are set.
132</dl>
133
134<P>
135
136<DIV CLASS="navigation">
137<div class='online-navigation'>
138<p></p><hr />
139<table align="center" width="100%" cellpadding="0" cellspacing="2">
140<tr>
141<td class='online-navigation'><a rel="prev" title="5.2.6.1 DocTest Objects"
142 href="doctest-DocTest.html"><img src='../icons/previous.png'
143 border='0' height='32' alt='Previous Page' width='32' /></A></td>
144<td class='online-navigation'><a rel="parent" title="5.2.6 Advanced API"
145 href="doctest-advanced-api.html"><img src='../icons/up.png'
146 border='0' height='32' alt='Up One Level' width='32' /></A></td>
147<td class='online-navigation'><a rel="next" title="5.2.6.3 DocTestFinder objects"
148 href="doctest-DocTestFinder.html"><img src='../icons/next.png'
149 border='0' height='32' alt='Next Page' width='32' /></A></td>
150<td align="center" width="100%">Python Library Reference</td>
151<td class='online-navigation'><a rel="contents" title="Table of Contents"
152 href="contents.html"><img src='../icons/contents.png'
153 border='0' height='32' alt='Contents' width='32' /></A></td>
154<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
155 border='0' height='32' alt='Module Index' width='32' /></a></td>
156<td class='online-navigation'><a rel="index" title="Index"
157 href="genindex.html"><img src='../icons/index.png'
158 border='0' height='32' alt='Index' width='32' /></A></td>
159</tr></table>
160<div class='online-navigation'>
161<b class="navlabel">Previous:</b>
162<a class="sectref" rel="prev" href="doctest-DocTest.html">5.2.6.1 DocTest Objects</A>
163<b class="navlabel">Up:</b>
164<a class="sectref" rel="parent" href="doctest-advanced-api.html">5.2.6 Advanced API</A>
165<b class="navlabel">Next:</b>
166<a class="sectref" rel="next" href="doctest-DocTestFinder.html">5.2.6.3 DocTestFinder objects</A>
167</div>
168</div>
169<hr />
170<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
171</DIV>
172<!--End of Navigation Panel-->
173<ADDRESS>
174See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
175</ADDRESS>
176</BODY>
177</HTML>