Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / module-test.testsupport.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-decimal.html" />
<link rel="prev" href="module-test.html" />
<link rel="parent" href="misc.html" />
<link rel="next" href="module-decimal.html" />
<meta name='aesop' content='information' />
<title>5.5 test.test_support -- Utility functions for tests</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.4.2 Running tests using"
href="regrtest.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
href="misc.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.6 decimal "
href="module-decimal.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="regrtest.html">5.4.2 Running tests using</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-decimal.html">5.6 decimal </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION007500000000000000000">
5.5 <tt class="module">test.test_support</tt> --
Utility functions for tests</A>
</H1>
<P>
<A NAME="module-test.testsupport"></A>
<P>
The <tt class="module">test.test_support</tt> module provides support for Python's
regression tests.
<P>
This module defines the following exceptions:
<P>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-1181' xml:id='l2h-1181' class="exception">TestFailed</tt></b></dt>
<dd>
Exception to be raised when a test fails.
</dd></dl>
<P>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-1182' xml:id='l2h-1182' class="exception">TestSkipped</tt></b></dt>
<dd>
Subclass of <tt class="exception">TestFailed</tt>.
Raised when a test is skipped.
This occurs when a needed resource (such as a network connection) is not
available at the time of testing.
</dd></dl>
<P>
<dl><dt><b><span class="typelabel">exception</span>&nbsp;<tt id='l2h-1183' xml:id='l2h-1183' class="exception">ResourceDenied</tt></b></dt>
<dd>
Subclass of <tt class="exception">TestSkipped</tt>.
Raised when a resource (such as a network connection) is not available.
Raised by the <tt class="function">requires()</tt> function.
</dd></dl>
<P>
The <tt class="module">test.test_support</tt> module defines the following constants:
<P>
<dl><dt><b><tt id='l2h-1184' xml:id='l2h-1184'>verbose</tt></b></dt>
<dd>
<tt class="constant">True</tt> when verbose output is enabled.
Should be checked when more detailed information is desired about a running
test.
<var>verbose</var> is set by <tt class="module">test.regrtest</tt>.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-1185' xml:id='l2h-1185'>have_unicode</tt></b></dt>
<dd>
<tt class="constant">True</tt> when Unicode support is available.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-1186' xml:id='l2h-1186'>is_jython</tt></b></dt>
<dd>
<tt class="constant">True</tt> if the running interpreter is Jython.
</dd></dl>
<P>
<dl><dt><b><tt id='l2h-1187' xml:id='l2h-1187'>TESTFN</tt></b></dt>
<dd>
Set to the path that a temporary file may be created at.
Any temporary that is created should be closed and unlinked (removed).
</dd></dl>
<P>
The <tt class="module">test.test_support</tt> module defines the following functions:
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1188' xml:id='l2h-1188' class="function">forget</tt></b>(</nobr></td>
<td><var>module_name</var>)</td></tr></table></dt>
<dd>
Removes the module named <var>module_name</var> from <code>sys.modules</code> and deletes
any byte-compiled files of the module.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1189' xml:id='l2h-1189' class="function">is_resource_enabled</tt></b>(</nobr></td>
<td><var>resource</var>)</td></tr></table></dt>
<dd>
Returns <tt class="constant">True</tt> if <var>resource</var> is enabled and available.
The list of available resources is only set when <tt class="module">test.regrtest</tt>
is executing the tests.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1190' xml:id='l2h-1190' class="function">requires</tt></b>(</nobr></td>
<td><var>resource</var><big>[</big><var>, msg</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Raises <tt class="exception">ResourceDenied</tt> if <var>resource</var> is not available.
<var>msg</var> is the argument to <tt class="exception">ResourceDenied</tt> if it is raised.
Always returns true if called by a function whose <code>__name__</code> is
<code>'__main__'</code>.
Used when tests are executed by <tt class="module">test.regrtest</tt>.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1191' xml:id='l2h-1191' class="function">findfile</tt></b>(</nobr></td>
<td><var>filename</var>)</td></tr></table></dt>
<dd>
Return the path to the file named <var>filename</var>.
If no match is found <var>filename</var> is returned.
This does not equal a failure since it could be the path to the file.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1192' xml:id='l2h-1192' class="function">run_unittest</tt></b>(</nobr></td>
<td><var>*classes</var>)</td></tr></table></dt>
<dd>
Execute <tt class="class">unittest.TestCase</tt> subclasses passed to the function.
The function scans the classes for methods starting with the prefix
"<tt class="samp">test_</tt>" and executes the tests individually.
This is the preferred way to execute tests.
</dl>
<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
<td><nobr><b><tt id='l2h-1193' xml:id='l2h-1193' class="function">run_suite</tt></b>(</nobr></td>
<td><var>suite</var><big>[</big><var>, testclass</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
Execute the <tt class="class">unittest.TestSuite</tt> instance <var>suite</var>.
The optional argument <var>testclass</var> accepts one of the test classes in the
suite so as to print out more detailed information on where the testing suite
originated from.
</dl>
<DIV CLASS="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5.4.2 Running tests using"
href="regrtest.html"><img src='../icons/previous.png'
border='0' height='32' alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="5. Miscellaneous Services"
href="misc.html"><img src='../icons/up.png'
border='0' height='32' alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="5.6 decimal "
href="module-decimal.html"><img src='../icons/next.png'
border='0' height='32' alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
href="contents.html"><img src='../icons/contents.png'
border='0' height='32' alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
border='0' height='32' alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
href="genindex.html"><img src='../icons/index.png'
border='0' height='32' alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="regrtest.html">5.4.2 Running tests using</A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="misc.html">5. Miscellaneous Services</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-decimal.html">5.6 decimal </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>