Back to index

python-biopython  1.60
Classes | Functions | Variables
run_tests Namespace Reference

Classes

class  ComparisonTestCase
class  TestRunner

Functions

def is_pypy
def is_numpy
def main

Variables

int VERBOSITY = 0
list DOCTEST_MODULES
tuple system_lang = os.environ.get('LANG', 'C')
tuple errors = main(sys.argv[1:])

Function Documentation

Definition at line 52 of file run_tests.py.

00052 
00053 def is_numpy():
00054     if is_pypy():
00055         return False
00056     try:
00057         import numpy
00058         del numpy
00059         return True
00060     except ImportError:
00061         return False
00062 
00063 # This is the list of modules containing docstring tests.
00064 # If you develop docstring tests for other modules, please add
# those modules here. Please sort names alphabetically.

Here is the call graph for this function:

Definition at line 42 of file run_tests.py.

00042 
00043 def is_pypy():
00044     import platform
00045     try:
00046         if platform.python_implementation()=='PyPy':
00047             return True
00048     except AttributeError:
00049         #New in Python 2.6, not in Jython yet either
00050         pass
00051     return False

Here is the caller graph for this function:

def run_tests.main (   argv)
Run tests, return number of failures (integer).

Definition at line 123 of file run_tests.py.

00123 
00124 def main(argv):
00125     """Run tests, return number of failures (integer)."""
00126     # insert our paths in sys.path:
00127     # ../build/lib.*
00128     # ..
00129     # Q. Why this order?
00130     # A. To find the C modules (which are in ../build/lib.*/Bio)
00131     # Q. Then, why ".."?
00132     # A. Because Martel may not be in ../build/lib.*
00133     test_path = sys.path[0] or "."
00134     source_path = os.path.abspath("%s/.." % test_path)
00135     sys.path.insert(1, source_path)
00136     build_path = os.path.abspath("%s/../build/lib.%s-%s" % (
00137         test_path, distutils.util.get_platform(), sys.version[:3]))
00138     if os.access(build_path, os.F_OK):
00139         sys.path.insert(1, build_path)
00140 
00141     # Using "export LANG=C" (which should work on Linux and similar) can
00142     # avoid problems detecting optional command line tools on
00143     # non-English OS (we may want 'command not found' in English).
00144     # HOWEVER, we do not want to change the default encoding which is
00145     # rather important on Python 3 with unicode.
00146     #lang = os.environ['LANG']
00147     
00148     # get the command line options
00149     try:
00150         opts, args = getopt.getopt(argv, 'gv', ["generate", "verbose",
00151             "doctest", "help", "offline"])
00152     except getopt.error, msg:
00153         print msg
00154         print __doc__
00155         return 2
00156 
00157     verbosity = VERBOSITY
00158 
00159     # deal with the options
00160     for o, a in opts:
00161         if o == "--help":
00162             print __doc__
00163             return 0
00164         if o == "--offline":
00165             print "Skipping any tests requiring internet access"
00166             #This is a bit of a hack...
00167             import requires_internet
00168             requires_internet.check.available = False
00169             #The check() function should now report internet not available
00170         if o == "-g" or o == "--generate":
00171             if len(args) > 1:
00172                 print "Only one argument (the test name) needed for generate"
00173                 print __doc__
00174                 return 2
00175             elif len(args) == 0:
00176                 print "No test name specified to generate output for."
00177                 print __doc__
00178                 return 2
00179             # strip off .py if it was included
00180             if args[0][-3:] == ".py":
00181                 args[0] = args[0][:-3]
00182 
00183             test = ComparisonTestCase(args[0])
00184             test.generate_output()
00185             return 0
00186 
00187         if o == "-v" or o == "--verbose":
00188             verbosity = 2
00189 
00190     # deal with the arguments, which should be names of tests to run
00191     for arg_num in range(len(args)):
00192         # strip off the .py if it was included
00193         if args[arg_num][-3:] == ".py":
00194             args[arg_num] = args[arg_num][:-3]
00195 
00196     print "Python version:", sys.version
00197     print "Operating system:", os.name, sys.platform
00198 
00199     # run the tests
00200     runner = TestRunner(args, verbosity)
00201     return runner.run()
00202 


Variable Documentation

Definition at line 65 of file run_tests.py.

tuple run_tests.errors = main(sys.argv[1:])

Definition at line 425 of file run_tests.py.

tuple run_tests.system_lang = os.environ.get('LANG', 'C')

Definition at line 121 of file run_tests.py.

Definition at line 27 of file run_tests.py.