Пример #1
0
def __run_test_module(module):
    env.threadlocal.MODULE_NAME = module.__name__.split('.')[-1]
    
    testcases = []
    for fun in dir(module):
        if (not fun.startswith("__")) and (not fun.endswith("__")) and (isinstance(module.__dict__.get(fun), types.FunctionType)):
            if  module.__dict__.get(fun).__module__ == module.__name__:
                testcases.append(fun)
    
    for testcase in testcases:
        if testcase == 'before_each_testcase' or testcase == 'after_each_testcase' or testcase == 'before_launch_browser':
            return
        
        for browser in env.TESTING_BROWSERS.split('|'):
            env.threadlocal.TESTING_BROWSER = browser
            if not hasattr(env.threadlocal, "BROWSER"): env.threadlocal.BROWSER = None
            
            ###### Run Test Case ######
            try:
                log.start_test(testcase)
                
                if hasattr(module, 'before_launch_browser'):
                    getattr(module, 'before_launch_browser')()
                
                if (env.RESTART_BROWSER == True) or (env.threadlocal.BROWSER == None):
                    env.threadlocal.BROWSER = launch_browser(env.BASE_URL)
                
                if hasattr(module, 'before_each_testcase'):
                    getattr(module, 'before_each_testcase')()
                
                getattr(module, testcase)()
                
                if hasattr(module, 'after_each_testcase'):
                    getattr(module, 'after_each_testcase')()
                
            except:
                log.handle_error()
            finally:
                if env.threadlocal.CASE_PASS == False:
                    env.threadlocal.casepass = False
                else:
                    env.threadlocal.casepass = True
                
                if env.threadlocal.CASE_PASS == False and env.FAST_FAIL == True:
                    log.stop_test()
                    return "FAST_FAIL"
                else:
                    log.stop_test()
                
                if (env.RESTART_BROWSER == True):
                    quit_browser(env.threadlocal.BROWSER)
                    env.threadlocal.BROWSER = None
                
                if (env.RESTART_BROWSER == False) and (env.threadlocal.BROWSER != None) and (env.threadlocal.casepass == False):
                    quit_browser(env.threadlocal.BROWSER)
                    env.threadlocal.BROWSER = None
    
    if (env.threadlocal.BROWSER != None):
        quit_browser(env.threadlocal.BROWSER)
        env.threadlocal.BROWSER = None
Пример #2
0
def __run_test_case(case):
    module = importlib.import_module(case.__module__)
    env.threadlocal.MODULE_NAME = case.__module__.split('.')[-1]

    for browser in env.TESTING_BROWSERS.split('|'):
        env.threadlocal.TESTING_BROWSER = browser
        if not hasattr(env.threadlocal, "BROWSER"):
            env.threadlocal.BROWSER = None

        ###### Run Test Case ######
        try:
            log.start_test(case.__name__)

            if hasattr(module, 'before_launch_browser'):
                getattr(module, 'before_launch_browser')()

            if (env.RESTART_BROWSER == True) or (env.threadlocal.BROWSER
                                                 == None):
                env.threadlocal.BROWSER = launch_browser(env.BASE_URL)

            if hasattr(module, 'before_each_testcase'):
                getattr(module, 'before_each_testcase')()

            case()

            if hasattr(module, 'after_each_testcase'):
                getattr(module, 'after_each_testcase')()

        except:
            log.handle_error()
        finally:
            if env.threadlocal.CASE_PASS == False:
                env.threadlocal.casepass = False
            else:
                env.threadlocal.casepass = True

            if env.threadlocal.CASE_PASS == False and env.FAST_FAIL == True:
                log.stop_test()
                return "FAST_FAIL"
            else:
                log.stop_test()

            if (env.RESTART_BROWSER == True):
                quit_browser(env.threadlocal.BROWSER)
                env.threadlocal.BROWSER = None

            if (env.RESTART_BROWSER
                    == False) and (env.threadlocal.BROWSER != None) and (
                        env.threadlocal.casepass == False):
                quit_browser(env.threadlocal.BROWSER)
                env.threadlocal.BROWSER = None

    if (env.threadlocal.BROWSER != None):
        quit_browser(env.threadlocal.BROWSER)
        env.threadlocal.BROWSER = None
Пример #3
0
def __run_test_case(case):
    module   = importlib.import_module(case.__module__)
    env.threadlocal.MODULE_NAME = case.__module__.split('.')[-1]
    
    for browser in env.TESTING_BROWSERS.split('|'):
        env.threadlocal.TESTING_BROWSER = browser
        if not hasattr(env.threadlocal, "BROWSER"): env.threadlocal.BROWSER = None
        
        ###### Run Test Case ######
        try:
            log.start_test(case.__name__)
            
            if hasattr(module, 'before_launch_browser'):
                getattr(module, 'before_launch_browser')()
            
            if (env.RESTART_BROWSER == True) or (env.threadlocal.BROWSER == None):
                env.threadlocal.BROWSER = launch_browser(env.BASE_URL)
            
            if hasattr(module, 'before_each_testcase'):
                getattr(module, 'before_each_testcase')()
            
            case()
            
            if hasattr(module, 'after_each_testcase'):
                getattr(module, 'after_each_testcase')()
            
        except:
            log.handle_error()
        finally:
            if env.threadlocal.CASE_PASS == False:
                env.threadlocal.casepass = False
            else:
                env.threadlocal.casepass = True
            
            if env.threadlocal.CASE_PASS == False and env.FAST_FAIL == True:
                log.stop_test()
                return "FAST_FAIL"
            else:
                log.stop_test()
            
            if (env.RESTART_BROWSER == True):
                quit_browser(env.threadlocal.BROWSER)
                env.threadlocal.BROWSER = None
            
            if (env.RESTART_BROWSER == False) and (env.threadlocal.BROWSER != None) and (env.threadlocal.casepass == False):
                quit_browser(env.threadlocal.BROWSER)
                env.threadlocal.BROWSER = None
    
    if (env.threadlocal.BROWSER != None):
        quit_browser(env.threadlocal.BROWSER)
        env.threadlocal.BROWSER = None
Пример #4
0
def __run_test_module(module):
    env.threadlocal.MODULE_NAME = module.__name__.split('.')[-1]

    testcases = []
    for fun in dir(module):
        if (not fun.startswith("__")) and (not fun.endswith("__")) and (
                isinstance(module.__dict__.get(fun), types.FunctionType)):
            if module.__dict__.get(fun).__module__ == module.__name__:
                testcases.append(fun)

    for testcase in testcases:
        if testcase == 'before_each_testcase' or testcase == 'after_each_testcase' or testcase == 'before_launch_browser':
            return

        for browser in env.TESTING_BROWSERS.split('|'):
            env.threadlocal.TESTING_BROWSER = browser
            if not hasattr(env.threadlocal, "BROWSER"):
                env.threadlocal.BROWSER = None

            ###### Run Test Case ######
            try:
                log.start_test(testcase)

                if hasattr(module, 'before_launch_browser'):
                    getattr(module, 'before_launch_browser')()

                if (env.RESTART_BROWSER == True) or (env.threadlocal.BROWSER
                                                     == None):
                    env.threadlocal.BROWSER = launch_browser(env.BASE_URL)

                if hasattr(module, 'before_each_testcase'):
                    getattr(module, 'before_each_testcase')()

                getattr(module, testcase)()

                if hasattr(module, 'after_each_testcase'):
                    getattr(module, 'after_each_testcase')()

            except:
                log.handle_error()
            finally:
                if env.threadlocal.CASE_PASS == False:
                    env.threadlocal.casepass = False
                else:
                    env.threadlocal.casepass = True

                if env.threadlocal.CASE_PASS == False and env.FAST_FAIL == True:
                    log.stop_test()
                    return "FAST_FAIL"
                else:
                    log.stop_test()

                if (env.RESTART_BROWSER == True):
                    quit_browser(env.threadlocal.BROWSER)
                    env.threadlocal.BROWSER = None

                if (env.RESTART_BROWSER
                        == False) and (env.threadlocal.BROWSER != None) and (
                            env.threadlocal.casepass == False):
                    quit_browser(env.threadlocal.BROWSER)
                    env.threadlocal.BROWSER = None

    if (env.threadlocal.BROWSER != None):
        quit_browser(env.threadlocal.BROWSER)
        env.threadlocal.BROWSER = None