Files
OpenShell/e2e/python/test_sandbox_exec_python.py
T
Alexander Watson 1d7909cb38 chore: add open-source compliance files and SPDX headers (#71)
Add Apache 2.0 licensing, SPDX copyright headers on all source files,
DCO enforcement, third-party notices, and CI enforcement.

- LICENSE: Apache License 2.0 full text
- DCO: Developer Certificate of Origin 1.1
- SPDX headers on all 176 source files (.rs, .py, .proto, .rego, .sh,
  .toml, .yaml, Dockerfiles)
- scripts/update_license_headers.py: header management with --check mode
- scripts/generate_third_party_notices.py: dependency license aggregation
- THIRD-PARTY-NOTICES: generated listing of all Rust and Python deps
- build/license.toml: mise tasks for license:check and license:update
- CI: license-headers job in checks.yml, DCO check workflow
- CONTRIBUTING.md: DCO sign-off requirement and license header docs
- Cargo.toml: license changed to Apache-2.0, repository URL updated
- pyproject.toml: license field added

Closes #58
2026-03-03 09:30:56 -08:00

43 lines
1.2 KiB
Python

# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from collections.abc import Callable
from navigator import Sandbox
def test_exec_python_accepts_bound_methods(
sandbox: Callable[..., Sandbox],
) -> None:
class _Calculator:
def multiply(self, left: int, right: int) -> int:
return left * right
with sandbox(delete_on_exit=True) as sb:
calculator = _Calculator()
result = sb.exec_python(calculator.multiply, args=(6, 7), timeout_seconds=20)
assert result.exit_code == 0
assert result.stdout.strip() == "42"
def test_exec_python_surfaces_callable_errors(
sandbox: Callable[..., Sandbox],
) -> None:
class _Boom:
def fail(self) -> None:
raise RuntimeError("expected-failure")
with sandbox(delete_on_exit=True) as sb:
result = sb.exec_python(_Boom().fail, timeout_seconds=20)
assert result.exit_code != 0
output = f"{result.stdout}\n{result.stderr}"
assert "expected-failure" in output
assert "RuntimeError" in output