          # Build graph
          graph = MigrationGraph()
          graph.add_node(("app_a", "0001"), None)
          msg = "Migration app_a.0002 dependencies reference nonexistent child node ('app_a', '0002')"
          with self.assertRaisesMessage(KeyError, msg):
              graph.add_dependency("app_a.0002", ("app_a", "0002"), ("app_a", "0001"))
 
</s> remove         with self.assertRaisesMessage(KeyError, msg):
 </s> add         with self.assertRaisesMessage(NodeNotFoundError, msg): </s> remove         with self.assertRaisesMessage(ValueError, message):
 </s> add         with self.assertRaisesMessage(NodeNotFoundError, message): </s> remove             raise KeyError(
                "Migration %s dependencies reference nonexistent child node %r" % (migration, child)
 </s> add             raise NodeNotFoundError(
                "Migration %s dependencies reference nonexistent child node %r" % (migration, child),
                child </s> remove             raise KeyError(
                "Migration %s dependencies reference nonexistent parent node %r" % (migration, parent)
 </s> add             raise NodeNotFoundError(
                "Migration %s dependencies reference nonexistent parent node %r" % (migration, parent),
                parent </s> remove                     self.graph.add_dependency(migration, child, key)
 </s> add                     try:
                        self.graph.add_dependency(migration, child, key)
                    except NodeNotFoundError as e:
                        # Since we added "key" to the nodes before this implies
                        # "child" is not in there.
                        _reraise_missing_dependency(migration, child, e)
        with self.assertRaisesMessage(NodeNotFoundError, msg):
          # Build graph
          graph = MigrationGraph()
          graph.add_node(("app_a", "0001"), None)
          msg = "Migration app_a.0002 dependencies reference nonexistent child node ('app_a', '0002')"
        with self.assertRaisesMessage(NodeNotFoundError, msg):
              graph.add_dependency("app_a.0002", ("app_a", "0002"), ("app_a", "0001"))
keep keep keep keep replace keep
 Fixed #23556 -- Raised a more meaningful error message when migrations refer to an unavailable node 
tests/migrations/test_graph.py