<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Testing — NetworkX 1.8.1 documentation</title> <link rel="stylesheet" href="_static/networkx.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '', VERSION: '1.8.1', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: false }; </script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within NetworkX 1.8.1 documentation" href="_static/opensearch.xml"/> <link rel="top" title="NetworkX 1.8.1 documentation" href="index.html" /> <link rel="next" title="Developer Guide" href="developer/index.html" /> <link rel="prev" title="Glossary" href="reference/glossary.html" /> </head> <body> <div style="color: black;background-color: white; font-size: 3.2em; text-align: left; padding: 15px 10px 10px 15px"> NetworkX </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="developer/index.html" title="Developer Guide" accesskey="N">next</a> |</li> <li class="right" > <a href="reference/glossary.html" title="Glossary" accesskey="P">previous</a> |</li> <li><a href="http://networkx.github.com/">NetworkX Home </a> | </li> <li><a href="http://networkx.github.com/documentation.html">Documentation </a>| </li> <li><a href="http://networkx.github.com/download.html">Download </a> | </li> <li><a href="http://github.com/networkx">Developer (Github)</a></li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Testing</a><ul> <li><a class="reference internal" href="#requirements-for-testing">Requirements for testing</a></li> <li><a class="reference internal" href="#testing-a-source-distribution">Testing a source distribution</a></li> <li><a class="reference internal" href="#testing-an-installed-package">Testing an installed package</a></li> <li><a class="reference internal" href="#testing-for-developers">Testing for developers</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="reference/glossary.html" title="previous chapter">Glossary</a></p> <h4>Next topic</h4> <p class="topless"><a href="developer/index.html" title="next chapter">Developer Guide</a></p> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="testing"> <h1>Testing<a class="headerlink" href="#testing" title="Permalink to this headline">¶</a></h1> <div class="section" id="requirements-for-testing"> <h2>Requirements for testing<a class="headerlink" href="#requirements-for-testing" title="Permalink to this headline">¶</a></h2> <p>NetworkX uses the Python nose testing package. If you don’t already have that package installed, follow the directions here <a class="reference external" href="http://somethingaboutorange.com/mrl/projects/nose">http://somethingaboutorange.com/mrl/projects/nose</a></p> </div> <div class="section" id="testing-a-source-distribution"> <h2>Testing a source distribution<a class="headerlink" href="#testing-a-source-distribution" title="Permalink to this headline">¶</a></h2> <p>You can test the complete package from the unpacked source directory with:</p> <div class="highlight-python"><pre>python setup_egg.py nosetests</pre> </div> </div> <div class="section" id="testing-an-installed-package"> <h2>Testing an installed package<a class="headerlink" href="#testing-an-installed-package" title="Permalink to this headline">¶</a></h2> <p>If you have a file-based (not a Python egg) installation you can test the installed package with</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">networkx</span> <span class="gp">>>> </span><span class="n">networkx</span><span class="o">.</span><span class="n">test</span><span class="p">()</span> </pre></div> </div> <p>or:</p> <div class="highlight-python"><pre>python -c "import networkx; networkx.test()"</pre> </div> </div> <div class="section" id="testing-for-developers"> <h2>Testing for developers<a class="headerlink" href="#testing-for-developers" title="Permalink to this headline">¶</a></h2> <p>You can test any or all of NetworkX by using the “nosetests” test runner.</p> <p>First make sure the NetworkX version you want to test is in your PYTHONPATH (either installed or pointing to your unpacked source directory).</p> <p>Then you can run individual test files with:</p> <div class="highlight-python"><pre>nosetests path/to/file</pre> </div> <p>or all tests found in dir and an directories contained in dir:</p> <div class="highlight-python"><pre>nosetests path/to/dir</pre> </div> <p>By default nosetests doesn’t test docutils style tests in Python modules but you can turn that on with:</p> <div class="highlight-python"><pre>nosetests --with-doctest</pre> </div> <p>For doctests in stand-alone files NetworkX uses the extension txt so you can add:</p> <div class="highlight-python"><pre>nosetests --with-doctest --doctest-extension=txt</pre> </div> <p>to also execute those tests.</p> <p>These options are on by default if you run nosetests from the root of the NetworkX distribution since they are specified in the setup.cfg file found there.</p> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="developer/index.html" title="Developer Guide" >next</a> |</li> <li class="right" > <a href="reference/glossary.html" title="Glossary" >previous</a> |</li> <li><a href="http://networkx.github.com/">NetworkX Home </a> | </li> <li><a href="http://networkx.github.com/documentation.html">Documentation </a>| </li> <li><a href="http://networkx.github.com/download.html">Download </a> | </li> <li><a href="http://github.com/networkx">Developer (Github)</a></li> </ul> </div> <div class="footer"> © Copyright 2013, NetworkX Developers. Last updated on Oct 23, 2013. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>