<s> from __future__ import print_function <EOL> import os , sys <EOL> _module_dir = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , "<STR_LIT>" ) <EOL> _module_name = os . path . basename ( os . path . dirname ( __file__ ) ) <EOL> ALERT_FILE = "<STR_LIT>" <EOL> TEST_PASS = "<STR_LIT>" <EOL> TEST_WARNING = "<STR_LIT>" <EOL> TEST_FAIL = "<STR_LIT>" <EOL> TEST_CRITICAL = "<STR_LIT>" <EOL> from . TestStatus import TestStatus <EOL> class __handler ( TestStatus ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , verbose = False , alert = False ) : <EOL> super ( self . __class__ , self ) . __init__ ( verbose , alert ) <EOL> self . _alert = False <EOL> class TestObject ( object ) : <EOL> def __init__ ( self , handler = None ) : <EOL> if handler is None : <EOL> self . _handler = __handler ( verbose = True ) <EOL> else : <EOL> self . _handler = handler <EOL> def Enabled ( self ) : <EOL> return True <EOL> def Test ( self ) : <EOL> return True <EOL> def Requires ( self ) : <EOL> return [ ] <EOL> def __LoadModule ( path , name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> if sys . version_info [ <NUM_LIT:0> ] < <NUM_LIT:3> : <EOL> import imp <EOL> return imp . load_source ( name , path ) <EOL> else : <EOL> if sys . version_info [ <NUM_LIT:1> ] < <NUM_LIT:5> : <EOL> from importlib . machinery import SourceFileLoader <EOL> return SourceFileLoader ( name , path ) . load_module ( ) <EOL> else : <EOL> import importlib . util <EOL> spec = importlib . util . spec_from_file_location ( name , path ) <EOL> rv = importlib . util . module_from_spec ( spec ) <EOL> spec . loader . exec_module ( rv ) <EOL> return rv <EOL> except : <EOL> return None <EOL> """<STR_LIT>""" <EOL> def Tests ( ) : <EOL> for fname in os . listdir ( _module_dir ) : <EOL> p = os . path . join ( _module_dir , fname ) <EOL> if not os . path . isfile ( p ) : <EOL> continue <EOL> if not p . endswith ( "<STR_LIT>" ) : <EOL> continue <EOL> if fname == "<STR_LIT>" : <EOL> continue <EOL> yield fname [ : - <NUM_LIT:3> ] <EOL> def RunTest ( name , handler ) : <EOL> """<STR_LIT>""" <EOL> test_path = os . path . join ( _module_dir , name + "<STR_LIT>" ) <EOL> try : <EOL> x = __LoadModule ( test_path , name ) <EOL> for test in x . List ( ) : <EOL> test_object = eval ( "<STR_LIT>" % test ) <EOL> if test_object . Enabled ( ) : <EOL> if not test_object . Test ( ) : <EOL> return False <EOL> except BaseException as e : <EOL> print ( "<STR_LIT>" % ( name , str ( e ) ) ) <EOL> return True </s>
