Source

pygame / docs / ref / tests.html

Full commit

<html>
<title>tests - Pygame Documentation</title>
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>


<table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
<tr>
<td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
<td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
	||&nbsp;
	<a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
	<a href=../index.html>Help Contents</a> &nbsp;||
	<a href=index.html>Reference Index</a> &nbsp;||
	<br>&nbsp;<br>
	
<a href="camera.html">Camera</a>&nbsp;||&nbsp;
<a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
<a href="color.html">Color</a>&nbsp;||&nbsp;
<a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
<a href="display.html">Display</a>&nbsp;||&nbsp;
<a href="draw.html">Draw</a>&nbsp;||&nbsp;
<a href="event.html">Event</a>&nbsp;||&nbsp;
<a href="examples.html">Examples</a>&nbsp;||&nbsp;
<a href="font.html">Font</a>&nbsp;||&nbsp;
<a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
<a href="image.html">Image</a>&nbsp;||&nbsp;
<a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
<a href="key.html">Key</a>&nbsp;||&nbsp;
<a href="locals.html">Locals</a>&nbsp;||&nbsp;
<a href="mask.html">Mask</a>&nbsp;||&nbsp;
<a href="midi.html">Midi</a>&nbsp;||&nbsp;
<a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
<a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
<a href="movie.html">Movie</a>&nbsp;||&nbsp;
<a href="music.html">Music</a>&nbsp;||&nbsp;
<a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
<a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
<a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
<a href="rect.html">Rect</a>&nbsp;||&nbsp;
<a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
<a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
<a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
<a href="surface.html">Surface</a>&nbsp;||&nbsp;
<a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
<a href="tests.html">Tests</a>&nbsp;||&nbsp;
<a href="time.html">Time</a>&nbsp;||&nbsp;
<a href="transform.html">Transform</a>
</td></tr></table>
<br>


<a name="pygame.tests">
<big><b>pygame.tests</big></b><br><ul>
  <i>Pygame unit test suite package</i><br>
<ul><small><table>
  <tr><td><a href="tests.html#pygame.tests.run">pygame.tests.run</a> - <font size=-1>Run the Pygame unit test suite</font></td><td>Run the Pygame unit test suite</td></tr>
</table></small></ul>
<p><tt>A</tt> quick way to run the test suite package from the command line is to import the go submodule with the Python -m option: </p>
<pre>  python -m pygame.tests [&lt;test options&gt;]
</pre><p>Command line option --help displays a usage message. Available options correspond to the <tt>pygame.tests.run</tt> arguments. </p>
<p>The xxxx_test submodules of the tests package are unit test suites for individual parts of Pygame. Each can also be run as a main program. This is useful if the test, such as cdrom_test, is interactive. </p>
<p>For Pygame development the test suite can be run from a Pygame distribution root directory. Program <tt>run_tests.py</tt> is provided for convenience, though <tt>test/go.py</tt> can be run directly. </p>
<p>Module level tags control which modules are included in a unit test run. Tags are assigned to a unit test module with a corresponding <tt>&lt;name&gt;_tags.py</tt> module. The tags module has the global __tags__, a list of tag names. For example, <tt>cdrom_test.py</tt> has a tag file <tt>cdrom_tags.py</tt> containing a tags list that has the 'interactive' string. The 'interactive' tag indicates <tt>cdrom_test.py</tt> expects user input. It is excluded from a <tt>run_tests.py</tt> or <tt>pygame.tests.go</tt> run. Two other tags that are excluded are 'ignore' and 'subprocess_ignore'. These two tags indicate unit tests that will not run on a particular platform, or for which no corresponding Pygame module is available. The test runner will list each excluded module along with the tag responsible. </p>
<!--COMMENTS:pygame.tests--> &nbsp;<br> 


<a name="pygame.tests.run">
<big><b>pygame.tests.run</big></b><br><ul>
  <i>Run the Pygame unit test suite</i><br>
  <tt>pygame.tests.run(*args, **kwds): return tuple</tt><br>
<p>Positional arguments (optional): </p>
<pre>    The names of tests to include. If omitted then all tests are run. Test names
    need not include the trailing '_test'.
</pre><p>Keyword arguments: </p>
<pre>    incomplete - fail incomplete tests (default False)
    nosubprocess - run all test suites in the current process
                   (default False, use separate subprocesses)
    dump - dump failures/errors as dict ready to eval (default False)
    file - if provided, the name of a file into which to dump failures/errors
    timings - if provided, the number of times to run each individual test to
              get an average run time (default is run each test once)
    exclude - A list of TAG names to exclude from the run
    show_output - show silenced stderr/stdout on errors (default False)
    all - dump all results, not just errors (default False)
    randomize - randomize order of tests (default False)
    seed - if provided, a seed randomizer integer
    multi_thread - if provided, the number of THREADS in which to run
                   subprocessed tests
    time_out - if subprocess is True then the time limit in seconds before
               killing a test (default 30)
    fake - if provided, the name of the fake tests package in the
           run_tests__tests subpackage to run instead of the normal
           Pygame tests
    python - the path to a python executable to run subprocessed tests
             (default sys.executable)
</pre><p>Return value: </p>
<pre>    A tuple of total number of tests run, dictionary of error information.
    The dictionary is empty if no errors were recorded.
</pre><p>By default individual test modules are run in separate subprocesses. This recreates normal Pygame usage where <tt><a href="pygame.html#pygame.init">pygame.init</a> - <font size=-1>initialize all imported pygame modules</font></tt> and <tt><a href="pygame.html#pygame.quit">pygame.quit</a> - <font size=-1>uninitialize all pygame modules</font></tt> are called only once per program execution, and avoids unfortunate interactions between test modules. Also, a time limit is placed on test execution, so frozen tests are killed when there time allotment expired. Use the single process option if threading is not working properly or if tests are taking too long. It is not guaranteed that all tests will pass in single process mode. </p>
<p>Tests are run in a randomized order if the randomize argument is True or a seed argument is provided. If no seed integer is provided then the system time is used. </p>
<p>Individual test modules may have a __tags__ attribute, a list of tag strings used to selectively omit modules from a run. By default only 'interactive' modules such as cdrom_test are ignored. An interactive module must be run from the console as a Python program. </p>
<p>This function can only be called once per Python session. It is not reentrant. </p>
<!--COMMENTS:pygame.tests.run--> &nbsp;<br> 
<br></ul>
<br></ul>

</body></html>