File: main.py

package info (click to toggle)
mobyle 1.5.5%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,288 kB
  • sloc: python: 22,709; makefile: 35; sh: 33; ansic: 10; xml: 6
file content (39 lines) | stat: -rwxr-xr-x 1,377 bytes parent folder | download | duplicates (4)
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
#! /usr/bin/env python

import os
import sys
import unittest2 as unittest

MOBYLEHOME = os.path.abspath( os.path.join( os.path.dirname( __file__ ) , "../../../" ) )
os.environ[ 'MOBYLEHOME' ] = MOBYLEHOME
if ( MOBYLEHOME ) not in sys.path:
    sys.path.append( MOBYLEHOME )
if ( os.path.join( MOBYLEHOME , 'Src' ) ) not in sys.path:    
    sys.path.append( os.path.join( MOBYLEHOME , 'Src' ) )
    
import Mobyle.Test.MobyleTest        
from optparse import OptionParser    
parser = OptionParser()
parser.add_option("-v", "--verbose" , 
                  dest= "verbosity" , 
                  action="count" , 
                  help= "set the verbosity level of output",
                  default = 0
                  )
opt , args = parser.parse_args()    

if not args:
    suite = unittest.TestLoader().discover( '.' ) 
else:
    suite = unittest.TestSuite()
    for arg in args: 
        if os.path.exists( arg ):
            if os.path.isfile( arg ):
                fpath, fname =  os.path.split( arg )
                suite.addTests( unittest.TestLoader().discover(  fpath , pattern = fname ) ) 
            elif os.path.isdir( arg ):  
                suite.addTests( unittest.TestLoader().discover( arg ) ) 
        else:
            sys.stderr.write(  "%s : no such file or directory\n" % arg ) 

unittest.TextTestRunner( verbosity = opt.verbosity ).run( suite )