Files
agent-sandbox/test_hello.py
T

31 lines
836 B
Python

import subprocess
import unittest
from pathlib import Path
class TestHello(unittest.TestCase):
def test_hello_output(self):
"""Test that hello.py prints 'Hello, World!' to stdout."""
result = subprocess.run(
["python3", "hello.py"],
capture_output=True,
text=True,
cwd=Path(__file__).parent
)
self.assertEqual(result.returncode, 0)
self.assertIn("Hello, World!", result.stdout)
def test_hello_no_stderr(self):
"""Test that hello.py produces no stderr output."""
result = subprocess.run(
["python3", "hello.py"],
capture_output=True,
text=True,
cwd=Path(__file__).parent
)
self.assertEqual(result.stderr, "")
if __name__ == "__main__":
unittest.main()