How to use the hacking.checks.mock_checks.MockCheckVisitor function in hacking

To help you get started, we’ve selected a few hacking examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / hacking / hacking / checks / mock_checks.py View on Github external
def run(self):
        mcv = MockCheckVisitor(self.filename)
        mcv.visit(self.tree)
        for message in mcv.messages:
            yield message
github openstack / hacking / hacking / checks / mock_checks.py View on Github external
if isinstance(call_node, ast.Call):
            func_info = FunctionNameFinder(self.filename)
            func_info.visit(call_node)

            # We are only looking at our patchers
            if func_info.function_name not in self.patchers:
                return

            min_args = self.patchers[func_info.function_name]

            if not find_autospec_keyword(call_node.keywords):
                if len(call_node.args) < min_args:
                    self.messages.append(
                        (call_node.lineno, call_node.col_offset,
                         "H210 Missing 'autospec' or 'spec_set' keyword in "
                         "mock.patch/mock.patch.object", MockCheckVisitor)
                    )
github openstack / hacking / hacking / checks / mock_checks.py View on Github external
def __init__(self, filename):
        super(MockCheckVisitor, self).__init__()
        self.messages = []
        self.filename = filename