@@ -93,11 +93,9 @@ def test_work_dir():
93
93
assert os .getcwd () == orig_cwd
94
94
95
95
96
- @pytest .mark .skipif (not os .path .exists ('/usr/bin/env' ),
97
- reason = "requires posix" )
98
- def test_env ():
99
- cmd = Command (['/usr/bin/env' ],
100
- env_vars = {'FOO' : 'BAR' , 'A' : 'B' })
96
+ @system_binary ('env' )
97
+ def test_env (env_binary ):
98
+ cmd = Command ([env_binary ], env_vars = {'FOO' : 'BAR' , 'A' : 'B' })
101
99
cmd .execute ()
102
100
assert "FOO=BAR\n " in cmd .getoutput ()
103
101
@@ -121,11 +119,10 @@ def test_command_to_str():
121
119
assert str (cmd ) == "foo bar"
122
120
123
121
124
- @pytest .mark .skipif (not os .path .exists ('/bin/sleep' ),
125
- reason = "requires /bin/sleep" )
126
- def test_command_timeout ():
122
+ @system_binary ('sleep' )
123
+ def test_command_timeout (sleep_binary ):
127
124
timeout = 30
128
- cmd = Command (["/bin/sleep" , str (timeout )], timeout = 3 )
125
+ cmd = Command ([sleep_binary , str (timeout )], timeout = 3 )
129
126
start_time = time .time ()
130
127
cmd .execute ()
131
128
# Check the process is no longer around.
@@ -138,11 +135,10 @@ def test_command_timeout():
138
135
assert cmd .getretcode () is None
139
136
140
137
141
- @pytest .mark .skipif (not os .path .exists ('/bin/sleep' ),
142
- reason = "requires /bin/sleep" )
143
- def test_command_notimeout ():
138
+ @system_binary ('sleep' )
139
+ def test_command_notimeout (sleep_binary ):
144
140
cmd_timeout = 30
145
- cmd = Command (["/bin/sleep" , "3" ], timeout = cmd_timeout )
141
+ cmd = Command ([sleep_binary , "3" ], timeout = cmd_timeout )
146
142
cmd .execute ()
147
143
assert cmd .getstate () == Command .FINISHED
148
144
assert cmd .getretcode () == 0
0 commit comments