Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ def test_rename_nodes():
assert ls0.name == "nodels"


def test_empty_graph():
"""Test edge-case behavior on a graph with no nodes."""
graph = Graph("")
assert graph.nodes == []

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Comparing graph.nodes (which is a DictModel instance) directly to a list [] will evaluate to False because DictModel is a custom container class and not a standard Python list. To check if the graph has no nodes, you should check its length or use its truthiness.

Suggested change
assert graph.nodes == []
assert len(graph.nodes) == 0

assert graph.nodesOfType("Ls") == []
assert graph.flowEdges() == []


class TestDFS:
""" Tests for the graph DFS traversal methods. """

Expand Down
8 changes: 4 additions & 4 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os

@contextmanager
def registeredNodeTypes(nodeTypes: list[desc.Node]):
def registeredNodeTypes(nodeTypes: list[type[desc.Node]]):
nodePluginsList = {}
for nodeType in nodeTypes:
nodePlugin = NodePlugin(nodeType)
Expand All @@ -22,7 +22,7 @@ def registeredNodeTypes(nodeTypes: list[desc.Node]):


@contextmanager
def overrideNodeTypeVersion(nodeType: desc.Node, version: str):
def overrideNodeTypeVersion(nodeType: type[desc.Node], version: str):
""" Helper context manager to override the version of a given node type. """
unpatchedFunc = meshroom.core.nodeVersion
with patch.object(
Expand All @@ -33,13 +33,13 @@ def overrideNodeTypeVersion(nodeType: desc.Node, version: str):
yield


def registerNodeDesc(nodeDesc: desc.Node):
def registerNodeDesc(nodeDesc: type[desc.Node]):
name = nodeDesc.__name__
if not pluginManager.isRegistered(name):
pluginManager._nodePlugins[name] = NodePlugin(nodeDesc)


def unregisterNodeDesc(nodeDesc: desc.Node):
def unregisterNodeDesc(nodeDesc: type[desc.Node]):
name = nodeDesc.__name__
if pluginManager.isRegistered(name):
del pluginManager._nodePlugins[name]
Expand Down
Loading