1+ import os
2+ import sys
13from io import StringIO
4+ import platform
25from contextlib import redirect_stdout , redirect_stderr
36
47import suby
8+ import pytest
59
610
7- def test_run_hello_world ():
11+ @pytest .mark .skipif (platform .system () == 'Windows' , reason = 'Windows and not windows have different rules of escaping characters.' )
12+ def test_run_hello_world_not_for_windows ():
813 stderr_buffer = StringIO ()
914 stdout_buffer = StringIO ()
1015
@@ -18,3 +23,21 @@ def test_run_hello_world():
1823 assert result .stderr == ''
1924 assert result .returncode == 0
2025 assert not result .killed_by_token
26+
27+
28+ @pytest .mark .skipif (platform .system () != 'Windows' , reason = 'Windows and not windows have different rules of escaping characters.' )
29+ def test_run_hello_world_windows ():
30+
31+ stderr_buffer = StringIO ()
32+ stdout_buffer = StringIO ()
33+
34+ with redirect_stdout (stdout_buffer ), redirect_stderr (stderr_buffer ):
35+ result = suby ('python' , '-c' , 'print("hello, world!")' )
36+
37+ assert stderr_buffer .getvalue () == ''
38+ assert stdout_buffer .getvalue () == 'hello, world!\n '
39+
40+ assert result .stdout == 'hello, world!\n '
41+ assert result .stderr == ''
42+ assert result .returncode == 0
43+ assert not result .killed_by_token
0 commit comments