예제 #1
0
    def __iter__(self):
        '''Built-in function __iter__

        Generator function, yielding each testable item within this container
        in the order of appearance inside the test cases. This is the main
        mechanism that allows looping through CleanTestcase Section's child
        items.

        This function relies on discover's returned list of sub sections in
        their sorted runtime order. It then takes each object class,
        instantiate them and run each. In case an object is looped, the loop
        iterations are processed.
        '''
        for section in self.discover():
            if not hasattr(section, '__testcls__'):
                raise TypeError("Expected a subsection object with "
                                "'__testcls__' set by the section decorator")
            # discovered Subsection
            # ------------------------
            if loopable(section):
                # section is marked to be looped
                # offer up each iteration in its own class instance
                for iteration in get_iterations(section):
                    new_section = section.__testcls__(section,
                                              uid = iteration.uid,
                                              parameters = iteration.parameters,
                                              parent = self)
                    yield new_section
            else:
                # run section a single time.
                new_section = section.__testcls__(section, parent = self)
                yield new_section
예제 #2
0
    def __iter__(self, *args, **kwargs):

        for section in self._discover():
            if loopable(section):
                for iteration in get_iterations(section):
                    new_section = section.__testcls__(section,
                                                      uid=iteration.uid,
                                                      parameters=iteration.parameters,
                                                      parent=self)
                    yield new_section
            else:
                new_section = section.__testcls__(section, parent=self)
                yield new_section
예제 #3
0
    def __iter__(self):
        '''Built-in function __iter__

        Generator function, yielding each testable item within this container
        in the order of appearance inside the test cases. This is the main
        mechanism that allows looping through CleanTestcase Section's child
        items.

        This function relies on discover's returned list of sub sections in
        their sorted runtime order. It then takes each object class,
        instantiate them and run each. In case an object is looped, the loop
        iterations are processed.
        '''
        for section in self.discover():

            if not hasattr(section, '__testcls__'):
                raise TypeError("Expected a subsection object with "
                                "'__testcls__' set by the section decorator")

            # If image handler has a method to update this section - execute it
            if self.image_handler:
                getattr(self.image_handler, 'update_section')(section.uid)

            # discovered Subsection
            # ------------------------
            if loopable(section):
                # section is marked to be looped
                # offer up each iteration in its own class instance
                for iteration in get_iterations(section):
                    new_section = section.__testcls__(
                        section,
                        uid=iteration.uid,
                        parameters=iteration.parameters,
                        parent=self)
                    yield new_section
            else:
                # run section a single time.
                new_section = section.__testcls__(section, parent=self)
                yield new_section

            if not new_section.result:
                # Do not run anything else as it did not passed
                log.error(banner("*** Terminating Genie Clean ***"))
                aetest.executer.goto_result = results.Blocked
                aetest.executer.goto = [[
                    '{} has not Passed'.format(new_section.uid), str
                ]]

            # image handler updates latest image
            if self.image_handler:
                self.image_handler.update_image_references(section)