Beispiel #1
0
    def print_unused_elements_warning(self):
        unused_elements = []
        
        for page_class in Page.all():
            page = page_class()
            if hasattr(page, "register"):
                page.register()
            if not page in self.used_elements:
                unused_elements.extend(page.registered_elements.keys())
            else:
                for element in page.registered_elements.keys():
                    element_key = '[%s] %s' % \
                                (page.__class__.__name__, element)
                                
                    if element not in self.used_elements.values() and \
                                element_key not in unused_elements:
                        unused_elements.append(element_key)

        if unused_elements:
            template = """${YELLOW}WARNING!
    ------------
    The following elements are registered but are never used: 

      *%s
    ------------
    ${NORMAL}
    """
            ctrl = TerminalController()
            print ctrl.render(template % "\n  *".join(unused_elements))
Beispiel #2
0
    def print_unused_elements_warning(self):
        unused_elements = []
        
        for page_class in Page.all():
            page = page_class()
            if hasattr(page, "register"):
                page.register()
            if not page in self.used_elements:
                unused_elements.extend(page.registered_elements.keys())
            else:
                for element in page.registered_elements.keys():
                    element_key = '[%s] %s' % \
                                (page.__class__.__name__, element)
                                
                    if element not in self.used_elements.values() and \
                                element_key not in unused_elements:
                        unused_elements.append(element_key)

        if unused_elements:
            template = """${YELLOW}WARNING!
    ------------
    The following elements are registered but are never used: 

      *%s
    ------------
    ${NORMAL}
    """
            ctrl = TerminalController()
            print ctrl.render(template % "\n  *".join(unused_elements))
Beispiel #3
0
 def print_results(self, language, results):
     if not results:
         return
     ctrl = TerminalController()
     print ctrl.render("${NORMAL}")
     print ctrl.render(results.summary_for(language))
     print "\n"
Beispiel #4
0
 def execute_after_tests(cls, results):
     ctrl = TerminalController()
     hooks_feedback = ctrl.render('${CYAN}')
     
     for hook in HOOKS['after_tests']:
         try:
             hook().execute(results)
             hooks_feedback += ctrl.render('[HOOKS] AfterTestsHook "%s" executed.\n' % hook)
         except Exception, e:
             raise HookError(e)
Beispiel #5
0
    def print_lxml_import_error(self):
        template = """${RED}REPORT ERROR
------------
Sorry, but you need to install lxml (python-lxml in aptitude or easy_install lxml)
before using the report feature in pyccuracy.
If you do not need a report use the -R=false parameter.
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template)
Beispiel #6
0
    def print_lxml_import_error(self):
        template = """${RED}REPORT ERROR
------------
Sorry, but you need to install lxml (python-lxml in aptitude or easy_install lxml)
before using the report feature in pyccuracy.
If you do not need a report use the -R=false parameter.
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template)
Beispiel #7
0
 def print_no_story_header(self, fixture, context):
     val = { 
             "has_no_header_files":True,
             "no_header_files":fixture.no_story_header
           }
     template_loader = TemplateLoader(context.language.key)
     template_string = template_loader.load('noheader')
     template = Template(template_string)
     msg = template.merge(val)
     ctrl = TerminalController()
     print ctrl.render(msg)
Beispiel #8
0
    def print_unused_actions_warning(self, unused_actions):
        template = """${YELLOW}WARNING!
------------
The following actions are never used: 

  *%s
------------
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template % "\n  *".join(unused_actions))
Beispiel #9
0
    def print_unused_actions_warning(self, unused_actions):
        template = """${YELLOW}WARNING!
------------
The following actions are never used: 

  *%s
------------
${NORMAL}
"""
        ctrl = TerminalController()
        print ctrl.render(template % "\n  *".join(unused_actions))
Beispiel #10
0
 def print_no_story_header(self, fixture, context):
     val = { 
             "has_no_header_files":True,
             "no_header_files":fixture.no_story_header
           }
     template_loader = TemplateLoader(context.language.key)
     template_string = template_loader.load('noheader')
     template = Template(template_string)
     msg = template.merge(val)
     ctrl = TerminalController()
     print ctrl.render(msg)
Beispiel #11
0
    def print_invalid_action(self, language, err):
        ctrl = TerminalController()
        template_text = TemplateLoader(language).load("invalid_scenario")
        template = Template(template_text)

        values = {
                    "action_text":err.line,
                    "scenario":err.scenario,
                    "filename":err.filename
                 }

        print ctrl.render(template.merge(values))
Beispiel #12
0
    def execute_after_tests(cls, results):
        if len(HOOKS['after_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['after_tests']:
                hook().execute(results)
                hooks_feedback += ctrl.render('[HOOKS] AfterTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Beispiel #13
0
    def execute_before_tests(cls):
        if len(HOOKS['before_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['before_tests']:
                hook().execute()
                hooks_feedback += ctrl.render('[HOOKS] BeforeTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Beispiel #14
0
    def execute_after_tests(cls, results):
        if len(HOOKS['after_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['after_tests']:
                hook().execute(results)
                hooks_feedback += ctrl.render(
                    '[HOOKS] AfterTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Beispiel #15
0
    def execute_before_tests(cls):
        if len(HOOKS['before_tests']) > 0:
            ctrl = TerminalController()
            hooks_feedback = ctrl.render('${CYAN}')

            for hook in HOOKS['before_tests']:
                hook().execute()
                hooks_feedback += ctrl.render(
                    '[HOOKS] BeforeTestsHook "%s" executed.\n' % hook)

            hooks_feedback += ctrl.render('${NORMAL}')
            hooks_feedback += "\n"

            print hooks_feedback
Beispiel #16
0
 def print_results(self, language, results):
     if not results:
         return
     ctrl = TerminalController()
     print ctrl.render("${NORMAL}")
     print ctrl.render(results.summary_for(language))
     print "\n"
Beispiel #17
0
    def run_stories(self, settings, fixture, context=None):
        if not context:
            context = self.create_context_for(settings)

        fixture.start_run()
        if settings.base_url:
            base_url = settings.base_url
        else:
            base_url = "http://localhost"

        try:
            context.browser_driver.start_test(base_url)
        except DriverError, err:
            ctrl = TerminalController()
            template_text = TemplateLoader(settings.default_culture).load("driver_error")
            template = Template(template_text)
            values = {"error": err, "browser_driver": context.browser_driver}
            print ctrl.render(template.merge(values))

            if settings.should_throw:
                raise TestFailedError("The test failed!")
            else:
                return None
Beispiel #18
0
    def run_stories(self, settings, fixture, context=None):
        if not context:
            context = self.create_context_for(settings)

        fixture.start_run()
        if settings.base_url:
            base_url = settings.base_url
        else:
            base_url = "http://localhost"

        try:
            context.browser_driver.start_test(base_url)
        except DriverError, err:
            ctrl = TerminalController()
            template_text = TemplateLoader(
                settings.default_culture).load("driver_error")
            template = Template(template_text)
            values = {"error": err, "browser_driver": context.browser_driver}
            print ctrl.render(template.merge(values))

            if settings.should_throw:
                raise TestFailedError("The test failed!")
            else:
                return None
Beispiel #19
0
    def print_invalid_action(self, language, err):
        ctrl = TerminalController()
        print ctrl.render("${NORMAL}")
        template_text = TemplateLoader(language).load("invalid_scenario")
        template = Template(template_text)

        values = {
                    "action_text":err.line,
                    "scenario":err.scenario,
                    "filename":err.filename
                 }

        print ctrl.render(template.merge(values))
Beispiel #20
0
from pyccuracy.core import PyccuracyCore
from pyccuracy.common import Status
from pyccuracy.story_runner import StoryRunner, ParallelStoryRunner
from pyccuracy import Version, Release
from pyccuracy.colored_terminal import ProgressBar, TerminalController

__version_string__ = "pyccuracy %s (release '%s')" % (Version, Release)
__docformat__ = 'restructuredtext en'

# fixing print in non-utf8 terminals
sys.stdout = codecs.getwriter('utf-8')(sys.stdout)

no_progress = False
prg = None
scenarios_ran = 0
ctrl = TerminalController()

def position(level, message, offset=4):
    offset_message = (level * offset) * " "
    line = "%s%s" % (offset_message, message)
    return line

def section_started_handler(section):
    print ctrl.render("${YELLOW}%s${NORMAL}" % position(1, section))

def before_action(context, action, args, kwarg):
    print ctrl.render("${WHITE}%s${NORMAL}" % position(2, action.description))

def action_successful(context, action, args, kwarg):
    print ctrl.render((ctrl.BOL + ctrl.UP + ctrl.CLEAR_EOL) * action.number_of_lines + "${GREEN}%s${NORMAL}" % position(2, action.description))