Statistics
| Branch: | Revision:

iof-tools / networkxMiCe / networkx-master / networkx / tests / test.py @ 5cef0f13

History | View | Annotate | Download (1.23 KB)

1
#!/usr/bin/env python
2
import sys
3
from os import path, getcwd
4

    
5

    
6
def run(verbosity=1, doctest=False, numpy=True):
7
    """Run NetworkX tests.
8

9
    Parameters
10
    ----------
11
    verbosity: integer, optional
12
      Level of detail in test reports.  Higher numbers provide more detail.
13

14
    doctest: bool, optional
15
      True to run doctests in code modules
16

17
    numpy: bool, optional
18
      True to test modules dependent on numpy
19
    """
20
    try:
21
        import nose
22
    except ImportError:
23
        raise ImportError(
24
            "The nose package is needed to run the NetworkX tests.")
25

    
26
    sys.stderr.write("Running NetworkX tests:")
27
    nx_install_dir = path.join(path.dirname(__file__), path.pardir)
28
    # stop if running from source directory
29
    if getcwd() == path.abspath(path.join(nx_install_dir, path.pardir)):
30
        raise RuntimeError("Can't run tests from source directory.\n"
31
                           "Run 'nosetests' from the command line.")
32

    
33
    argv = [' ', '--verbosity=%d' % verbosity,
34
            '-w', nx_install_dir,
35
            '-exe']
36
    if doctest:
37
        argv.extend(['--with-doctest', '--doctest-extension=txt'])
38
    if not numpy:
39
        argv.extend(['-A not numpy'])
40

    
41
    nose.run(argv=argv)
42

    
43

    
44
if __name__ == "__main__":
45
    run()