Beispiel #1
0
 def _handle_file_update(self, filepath: str):
     """Handle a file being created or modified."""
     if self._watch_mode == "collect":
         root_node = plugin.collect_path(filepath, self._directory)
         self.result_tree.merge(
             root_node, nodeid.Nodeid.from_path(filepath, self._directory))
         self._send_update()
     else:
         test_nodeid = nodeid.Nodeid.from_path(filepath, self._directory)
         self._run_test(test_nodeid)
Beispiel #2
0
def _init_result_tree(
    directory: str,
) -> result_tree.BranchNode:
    """Collect the tests and initialise the result tree skeleton."""
    root_node = plugin.collect_path(directory, directory)

    if len(root_node.child_branches) == 0 and len(root_node.child_leaves) == 0:
        raise RuntimeError(f"failed to collect any tests from {directory}")

    return root_node
Beispiel #3
0
 def _handle_file_moved(self, src_path: str, dest_path: str):
     """Handle a file being moved."""
     orig_nodeid = nodeid.Nodeid.from_path(src_path, self._directory)
     try:
         self._pop_node(orig_nodeid)
     except KeyError:
         LOGGER.debug("could not find node in tree: %s", orig_nodeid)
         return
     collect_root = plugin.collect_path(dest_path, self._directory)
     self.result_tree.merge(collect_root)
     self._send_update()
Beispiel #4
0
 def _handle_file_update(self, filepath: str):
     """Handle a file being created or modified."""
     root_node = plugin.collect_path(filepath, self._directory)
     self.result_tree.merge(root_node)
     self._send_update()