diff --git a/tests/test_compute.py b/tests/test_compute.py index f28e436c25..8678251982 100644 --- a/tests/test_compute.py +++ b/tests/test_compute.py @@ -8,6 +8,8 @@ import os import re +import shlex +from types import SimpleNamespace from pathlib import Path import logging @@ -159,6 +161,33 @@ def test_process(self, tmp_path): reg = re.compile(self.logPrefix + "TestNodeC_1") assert len(reg.findall(content)) == 1 + def test_processChunkInEnvironment_quotesGraphFilepathWithSpaces(self, tmp_path): + graphFilepath = Path(tmp_path, "project with spaces", "scene with spaces.mg") + graphFilepath.parent.mkdir() + + nodeDesc = desc.Node() + executed = {} + + def executeChunkCommandLine(chunk, cmd, env=None): + executed["cmd"] = cmd + executed["env"] = env + + nodeDesc.executeChunkCommandLine = executeChunkCommandLine + plugin = SimpleNamespace(runtimeEnv=None, commandPrefix="", commandSuffix="") + node = SimpleNamespace( + name="TestNode_1", + graph=SimpleNamespace(filepath=graphFilepath.as_posix()), + nodeDesc=SimpleNamespace(pythonExecutable="python", plugin=plugin), + getChunks=lambda: [object(), object()], + ) + chunk = SimpleNamespace(node=node, range=SimpleNamespace(iteration=1)) + + nodeDesc.processChunkInEnvironment(chunk) + + assert f'"{graphFilepath.as_posix()}"' in executed["cmd"] + assert shlex.split(executed["cmd"])[2] == graphFilepath.as_posix() + assert "--iteration 1" in executed["cmd"] + class TestLockUpdates: """