Skip to content
Open
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
29 changes: 29 additions & 0 deletions tests/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import os
import re
import shlex
from types import SimpleNamespace
from pathlib import Path
import logging

Expand Down Expand Up @@ -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:
"""
Expand Down
Loading