NodeOperationError: Command failed when trying to run pytest command in Execute Command

Hi
I have an issue running pytest commands from the Execute Command node. I’m running the docker container with python and pytest installed. if I run the command “python -m pytest” in the container at /home/node I get a pytest output. If I run that command in Execute Command I get the following error.

Item Index

0

Node type

n8n-nodes-base.executeCommand

Node version

1 (Latest)

n8n version

1.98.1 (Self Hosted)

NodeOperationError: Command failed: python -m pytest at ExecuteContext.execute (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-nodes-base@file+packages+nodes-base_@[email protected]_asn1.js@5_12b981d6b49d407a163f4d5244314033/node_modules/n8n-nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts:102:12) at processTicksAndRejections (node:internal/process/task_queues:105:5) at WorkflowExecute.runNode (/usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1185:9) at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:1534:27 at /usr/local/lib/node_modules/n8n/node_modules/.pnpm/n8n-core@[email protected][email protected][email protected]_/node_modules/n8n-core/src/execution-engine/workflow-execute.ts:2098:11

n8n 1.98.1
SQLLite
Docker
Windows 11

Try running it this way:

test_results=$(python -m pytest)
echo $test_results
1 Like

Awesome that worked. Thank you.

I don’t suppose you know how to do the same thing but with in a Windows env?

I don’t have a windows machine handy to test, but something like this, maybe?

$test_results = python -m pytest
Write-Output $test_results

if we are talking powershell.