[tests] Simplify registration/unregistration of nodes in tests

Add two methods that are local to tests, `registerNodeDesc` and
`unregisterNodeDesc`, which handle the registration and unregistration
of `NodePlugins` from a node description. This reduces the amount of
code in tests whenever `NodePlugin` need to be instantiated prior
to their registration and so on.
This commit is contained in:
Candice Bentéjac 2025-06-04 21:18:16 +02:00
parent 424abbff82
commit 3c57afb4d0
8 changed files with 76 additions and 77 deletions

View file

@ -1,7 +1,7 @@
from meshroom.core import desc, pluginManager
from meshroom.core.plugins import NodePlugin
from meshroom.core.graph import Graph, loadGraph
from .utils import registerNodeDesc, unregisterNodeDesc
class NodeWithChoiceParams(desc.Node):
inputs = [
@ -53,15 +53,14 @@ class NodeWithChoiceParamsSavingValuesOverride(desc.Node):
class TestChoiceParam:
nodePlugin = NodePlugin(NodeWithChoiceParams)
@classmethod
def setup_class(cls):
pluginManager.registerNode(cls.nodePlugin)
registerNodeDesc(NodeWithChoiceParams)
@classmethod
def teardown_class(cls):
pluginManager.unregisterNode(cls.nodePlugin)
unregisterNodeDesc(NodeWithChoiceParams)
def test_customValueIsSerialized(self, graphSavedOnDisk):
graph: Graph = graphSavedOnDisk
@ -120,15 +119,14 @@ class TestChoiceParam:
class TestChoiceParamSavingCustomValues:
nodePlugin = NodePlugin(NodeWithChoiceParamsSavingValuesOverride)
@classmethod
def setup_class(cls):
pluginManager.registerNode(cls.nodePlugin)
registerNodeDesc(NodeWithChoiceParamsSavingValuesOverride)
@classmethod
def teardown_class(cls):
pluginManager.unregisterNode(cls.nodePlugin)
unregisterNodeDesc(NodeWithChoiceParamsSavingValuesOverride)
def test_customValueIsSerialized(self, graphSavedOnDisk):
graph: Graph = graphSavedOnDisk