Ejemplo n.º 1
0
    def visit_FunctionDef(self, node):
        """Visitor for AST FunctionDef nodes

        add relevant information about the node to
        the context for use in tests which inspect function definitions.
        Add the function name to the current namespace for all descendants.
        :param node: The node that is being inspected
        :return: -
        """

        self.context["function"] = node

        if self.debug:
            logger.debug("visit_FunctionDef called (%s)", ast.dump(node))

        qualname = self.namespace + "." + b_utils.get_func_name(node)
        name = qualname.split(".")[-1]

        self.context["qualname"] = qualname
        self.context["name"] = name

        # For all child nodes and any tests run, add this function name to
        # current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, name)
        self.update_scores(self.tester.run_tests(self.context, "FunctionDef"))
        self.generic_visit(node)
        self.namespace = b_utils.namespace_path_split(self.namespace)[0]
Ejemplo n.º 2
0
    def visit_FunctionDef(self, node):
        '''Visitor for AST FunctionDef nodes

        add relevant information about the node to
        the context for use in tests which inspect function definitions.
        Add the function name to the current namespace for all descendants.
        :param node: The node that is being inspected
        :return: -
        '''

        self.context['function'] = node

        if self.debug:
            self.logger.debug("visit_FunctionDef called (%s)", ast.dump(node))

        qualname = self.namespace + '.' + b_utils.get_func_name(node)
        name = qualname.split('.')[-1]

        self.context['qualname'] = qualname
        self.context['name'] = name

        # For all child nodes and any tests run, add this function name to
        # current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, name)
        self.update_scores(self.tester.run_tests(self.context, 'FunctionDef'))
        self.generic_visit(node)
        self.namespace = b_utils.namespace_path_split(self.namespace)[0]
Ejemplo n.º 3
0
    def visit_ClassDef(self, node):
        '''Visitor for AST ClassDef node

        Add class name to current namespace for all descendants.
        :param node: Node being inspected
        :return: -
        '''
        # For all child nodes, add this class name to current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, node.name)
Ejemplo n.º 4
0
    def visit_ClassDef(self, node):
        '''Visitor for AST ClassDef node

        Add class name to current namespace for all descendants.
        :param node: Node being inspected
        :return: -
        '''
        # For all child nodes, add this class name to current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, node.name)
Ejemplo n.º 5
0
    def visit_ClassDef(self, node):
        """Visitor for AST ClassDef node

        Add class name to current namespace for all descendants.
        :param node: Node being inspected
        :return: -
        """

        if self.debug:
            logger.debug("visit_ClassDef called (%s)", ast.dump(node))

        # For all child nodes, add this class name to current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, node.name)
        self.generic_visit(node)
        self.namespace = b_utils.namespace_path_split(self.namespace)[0]
Ejemplo n.º 6
0
    def visit_ClassDef(self, node):
        '''Visitor for AST ClassDef node

        Add class name to current namespace for all descendants.
        :param node: Node being inspected
        :return: -
        '''

        if self.debug:
            self.logger.debug("visit_ClassDef called (%s)", ast.dump(node))

        # For all child nodes, add this class name to current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, node.name)
        self.generic_visit(node)
        self.namespace = b_utils.namespace_path_split(self.namespace)[0]
Ejemplo n.º 7
0
    def visit_FunctionDef(self, node):
        '''Visitor for AST FunctionDef nodes

        add relevant information about the node to
        the context for use in tests which inspect function definitions.
        Add the function name to the current namespace for all descendants.
        :param node: The node that is being inspected
        :return: -
        '''

        self.context['function'] = node
        qualname = self.namespace + '.' + b_utils.get_func_name(node)
        name = qualname.split('.')[-1]

        self.context['qualname'] = qualname
        self.context['name'] = name

        # For all child nodes and any tests run, add this function name to
        # current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, name)
        self.update_scores(self.tester.run_tests(self.context, 'FunctionDef'))
Ejemplo n.º 8
0
    def visit_FunctionDef(self, node):
        """Visitor for AST FunctionDef nodes

        add relevant information about the node to
        the context for use in tests which inspect function definitions.
        Add the function name to the current namespace for all descendants.
        :param node: The node that is being inspected
        :return: -
        """

        self.context["function"] = node
        qualname = self.namespace + "." + b_utils.get_func_name(node)
        name = qualname.split(".")[-1]

        self.context["qualname"] = qualname
        self.context["name"] = name

        # For all child nodes and any tests run, add this function name to
        # current namespace
        self.namespace = b_utils.namespace_path_join(self.namespace, name)
        self.update_scores(self.tester.run_tests(self.context, "FunctionDef"))
Ejemplo n.º 9
0
 def test_namespace_path_join(self):
     p = b_utils.namespace_path_join('base1.base2', 'name')
     self.assertEqual('base1.base2.name', p)
Ejemplo n.º 10
0
 def test_namespace_path_join(self):
     p = b_utils.namespace_path_join('base1.base2', 'name')
     self.assertEqual('base1.base2.name', p)
Ejemplo n.º 11
0
 def test_namespace_path_join(self):
     p = b_utils.namespace_path_join("base1.base2", "name")
     self.assertEqual("base1.base2.name", p)
Ejemplo n.º 12
0
 def test_namespace_path_join(self):
     p = b_utils.namespace_path_join("base1.base2", "name")
     self.assertEqual("base1.base2.name", p)