File: test.py

package info (click to toggle)
htseq 0.6.1p1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 71,144 kB
  • ctags: 484
  • sloc: python: 1,521; cpp: 139; makefile: 131; sh: 5
file content (39 lines) | stat: -rw-r--r-- 1,138 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import sys, os, glob, os.path
import distutils.util
import doctest

import matplotlib
matplotlib.use('agg')

build_dir = "build/lib.%s-%s" % ( distutils.util.get_platform(), sys.version[0:3] )

sys.path.insert( 0, os.path.join( os.getcwd(), build_dir ) )
import HTSeq
os.chdir( "example_data" )

def test_rst_file( filename ):
   print "Doctest of %s:" % os.path.basename( filename )
   (failure_count, test_count) = doctest.testfile( 
      os.path.join( "..", "doc", filename ), module_relative=False )

   if failure_count == 0:
      print "All %d tests passed." % test_count
      return True
   else:   
      print "%d of %d tests failed." % (failure_count, test_count)
      return False

ok = True
if len(sys.argv) == 1:
   for fn in glob.glob( "../doc/*.rst" ):
      ok &= test_rst_file( os.path.basename( fn ) )
      print
   if not ok:
      print "Not all tests passed."
      exit( 1 )
elif len(sys.argv) == 2:
   test_rst_file( sys.argv[1] )
else:
   print "Wrong usage"
   print "Call without arguments to run all doctest, or with the (base) name"
   print "of one rst file from the doc directory to run doctest on it."