Files
invoke-ai--invokeai/tests/test_dangerously_run_function_in_subprocess.py
wehub-resource-sync cddb07a176
build container image / cpu (push) Waiting to run
build container image / cuda (push) Waiting to run
build container image / rocm (push) Waiting to run
frontend tests / frontend-tests (push) Waiting to run
openapi checks / openapi-checks (push) Waiting to run
python tests / py3.12: macos-default (push) Waiting to run
python tests / py3.11: windows-cpu (push) Waiting to run
python tests / py3.12: windows-cpu (push) Waiting to run
python tests / py3.11: linux-cpu (push) Waiting to run
python tests / py3.12: linux-cpu (push) Waiting to run
typegen checks / typegen-checks (push) Waiting to run
uv lock checks / uv-lock-checks (push) Waiting to run
frontend checks / frontend-checks (push) Waiting to run
lfs checks / lfs-check (push) Waiting to run
python checks / python-checks (push) Waiting to run
python tests / py3.11: macos-default (push) Waiting to run
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:22:06 +08:00

58 lines
1.4 KiB
Python

from tests.dangerously_run_function_in_subprocess import dangerously_run_function_in_subprocess
def test_simple_function():
def test_func():
print("Hello, Test!")
stdout, stderr, returncode = dangerously_run_function_in_subprocess(test_func)
assert returncode == 0
assert stdout.strip() == "Hello, Test!"
assert stderr == ""
def test_function_with_error():
def test_func():
raise ValueError("This is an error")
_stdout, stderr, returncode = dangerously_run_function_in_subprocess(test_func)
assert returncode != 0 # Should fail
assert "ValueError: This is an error" in stderr
def test_function_with_imports():
def test_func():
import math
print(math.sqrt(4))
stdout, stderr, returncode = dangerously_run_function_in_subprocess(test_func)
assert returncode == 0
assert stdout.strip() == "2.0"
assert stderr == ""
def test_function_with_sys_exit():
def test_func():
import sys
sys.exit(42)
_stdout, _stderr, returncode = dangerously_run_function_in_subprocess(test_func)
assert returncode == 42 # Should return the custom exit code
def test_function_with_closure():
foo = "bar"
def test_func():
print(foo)
_stdout, _stderr, returncode = dangerously_run_function_in_subprocess(test_func)
assert returncode == 1 # Should fail because of closure