def _sibling_is_test(source_set): """Determine if a SourceSet represents a test path. Non test targets that otherwise live in test target roots (say a java_library), must be marked as test for IDEA to correctly link the targets with the test code that uses them. Therefore we check to see if the source root registered to the path or any of its sibling source roots are defined with a test type. :param source_set: SourceSet to analyze :returns: True if the SourceSet represents a path containing tests """ def has_test_type(types): for target_type in types: # TODO(Eric Ayers) Find a way for a target to identify itself instead of a hard coded list if target_type in (JavaTests, PythonTests): return True return False if source_set.path: path = os.path.join(source_set.source_base, source_set.path) else: path = source_set.source_base sibling_paths = SourceRoot.find_siblings_by_path(path) for sibling_path in sibling_paths: if has_test_type(SourceRoot.types(sibling_path)): return True return False