def _find_xctest_tests()

in testinggame/__init__.py [0:0]


def _find_xctest_tests(blame_lines, names, source, xctestsuperclasses):
    """
    Finds the number of XCTest cases per user.

    Args:
        blame_lines: An array where each index is a string containing the git
        blame line.
        names: The current dictionary containing the usernames as a key and the
        number of tests as a value.
        source: A string containing the raw source code for the file.
        xctestsuperclasses: An array containing alternative superclasses for
        the xctest framework.
    Returns:
        A dictionary built off the names argument containing the usernames as a
        key and the number of tests as a value.
    """
    xctest_identifiers = ['XCTestCase']
    xctest_identifiers.extend(xctestsuperclasses)
    contains_test_case = False
    for xctest_identifier in xctest_identifiers:
        contains_test_case |= source.find(xctest_identifier) != -1
        if contains_test_case:
            break
    if contains_test_case:
        for blame_line in blame_lines:
            if blame_line.replace(' ', '').find('-(void)test') != -1:
                name = _find_name_from_blame(blame_line)
                name_count = names.get(name, 0)
                names[name] = name_count + 1
    return names