Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubno committed Jan 24, 2025
1 parent 1829790 commit ae61d83
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/python-sdk/tests/sync/sandbox_sync/commands/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ def test_run_with_special_characters(sandbox: Sandbox):
assert cmd.exit_code == 0
assert cmd.stdout == f"{text}\n"


def test_run_with_broken_utf8(sandbox: Sandbox):
# Create a string with 8191 'a' characters followed by the problematic byte 0xe2
long_str = 'a' * 8191 + '\\xe2'
long_str = "a" * 8191 + "\\xe2"
result = sandbox.commands.run(f'printf "{long_str}"')
assert result.exit_code == 0

# The broken UTF-8 bytes should be replaced with the Unicode replacement character
assert result.stdout == ('a' * 8191 + '\ufffd')
assert result.stdout == ("a" * 8191 + "\ufffd")


def test_run_with_multiline_string(sandbox):
text = "Hello,\nWorld!"
Expand All @@ -47,3 +49,10 @@ def test_run_with_timeout(sandbox):
def test_run_with_too_short_timeout(sandbox):
with pytest.raises(TimeoutException):
sandbox.commands.run("sleep 10", timeout=2)


def test_run_with_too_short_timeout_iterating(sandbox):
cmd = sandbox.commands.run("sleep 10", timeout=2, background=True)
with pytest.raises(TimeoutException):
for _ in cmd:
pass

0 comments on commit ae61d83

Please sign in to comment.