How to use the betelgeuse.collector.TestFunction function in Betelgeuse

To help you get started, we’ve selected a few Betelgeuse 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 SatelliteQE / betelgeuse / betelgeuse / collector.py View on Github external
def _get_tests(path):
    """Collect tests for the test module located at ``path``."""
    tests = []
    with open(path) as handler:
        root = ast.parse(handler.read())
        root.path = path  # TODO improve how to pass the path to TestFunction
        for node in ast.iter_child_nodes(root):
            if isinstance(node, ast.ClassDef):
                [
                    tests.append(TestFunction(subnode, node, root))
                    for subnode in ast.iter_child_nodes(node)
                    if isinstance(subnode, ast.FunctionDef) and
                    subnode.name.startswith('test_')
                ]
            elif (isinstance(node, ast.FunctionDef) and
                    node.name.startswith('test_')):
                tests.append(TestFunction(node, testmodule=root))
    return tests
github SatelliteQE / betelgeuse / betelgeuse / collector.py View on Github external
"""Collect tests for the test module located at ``path``."""
    tests = []
    with open(path) as handler:
        root = ast.parse(handler.read())
        root.path = path  # TODO improve how to pass the path to TestFunction
        for node in ast.iter_child_nodes(root):
            if isinstance(node, ast.ClassDef):
                [
                    tests.append(TestFunction(subnode, node, root))
                    for subnode in ast.iter_child_nodes(node)
                    if isinstance(subnode, ast.FunctionDef) and
                    subnode.name.startswith('test_')
                ]
            elif (isinstance(node, ast.FunctionDef) and
                    node.name.startswith('test_')):
                tests.append(TestFunction(node, testmodule=root))
    return tests