Ejemplo n.º 1
0
def run_story_scenario(
    storyfile,
    scenario=None,
    before_all_methods=None,
    after_all_methods=None,
    before_each_methods=None,
    after_each_methods=None,
):
    global _steps_modules
    steps_modules = _steps_modules

    if not os.path.exists(storyfile):
        storyfile = extasy.settings.get("_stories_dir") + "/" + storyfile

    if not os.path.exists(storyfile):
        raise Exception('Story file "%s" does not exist' % storyfile)

    hook_steps = extasy_find_hook_steps(storyfile)

    before_all_methods = before_all_methods or []
    after_all_methods = after_all_methods or []
    before_each_methods = before_each_methods or []
    after_each_methods = after_each_methods or []

    before_all_methods += hook_steps.get("_before_alls", [])
    after_all_methods += hook_steps.get("_after_alls", [])
    before_each_methods += hook_steps.get("_before_eachs", [])
    after_each_methods += hook_steps.get("_after_eachs", [])

    colored = True
    if extasy.settings.get("no_colors"):
        colored = False

    story_output = StringIO.StringIO()
    story_runner = StoryRunner(
        open(storyfile).read(),
        story_output,
        colored=colored,
        modules=steps_modules,
        language=extasy.settings.get("language", "en-us"),
        before_all=before_all_methods,
        before_each=before_each_methods,
        after_all=after_all_methods,
        after_each=after_each_methods,
    )
    story_runner._story_file = storyfile

    story_status = story_runner.run(scenarios=[scenario])

    if not story_status:
        print story_output.read()
    return story_status
Ejemplo n.º 2
0
    exit_code = True
    
    extasy.selenium.getDriver().start_test()
    for index, story in enumerate(files):
        hook_steps = extasy_find_hook_steps( story )
        before_all_methods += hook_steps.get( '_before_alls', [] )
        after_all_methods += hook_steps.get( '_after_alls', [] )
        before_each_methods += hook_steps.get( '_before_eachs', [] )
        after_each_methods += hook_steps.get( '_after_eachs', [] )
        
        story_runner = StoryRunner(open(story).read(),
                                         sys.stdout,
                                         colored=colored,
                                         modules=steps_modules,
                                         language=values.language,
                                         before_all=before_all_methods,
                                         before_each=before_each_methods,
                                         after_all=after_all_methods,
                                         after_each=after_each_methods)
        
        story_runner._story_file = story
        
        story_status = story_runner.run()
        exit_code = exit_code and story_status
        if index < len(files)-1:
            sys.stdout.write('\n\n')

    extasy.selenium.getDriver().stop_test()
    
    exit(int(not exit_code))