@@ -73,15 +73,16 @@ def fixture_test_dir() -> Generator[str, None, None]:
73
73
sys .stderr .write ("test temp dir: {}\n " .format (my_dir ))
74
74
boxes = list_box_names ()
75
75
if TEST_BOX_NAME not in boxes :
76
- cmd = f "vagrant box add --provider { TEST_PROVIDER } { TEST_BOX_URL } "
77
- subprocess .check_call (cmd , shell = True )
76
+ cmd = [ "vagrant" , " box" , " add" , " --provider" , TEST_PROVIDER , TEST_BOX_URL ]
77
+ subprocess .check_call (cmd )
78
78
79
79
yield my_dir
80
80
# Removes the directory created initially, runs once after the last test
81
81
sys .stderr .write ("module teardown()\n " )
82
82
if my_dir is not None :
83
83
try :
84
- subprocess .check_call ("vagrant destroy -f" , cwd = my_dir , shell = True )
84
+ cmd = ["vagrant" , "destroy" , "-f" ]
85
+ subprocess .check_call (cmd , cwd = my_dir )
85
86
except subprocess .CalledProcessError :
86
87
pass
87
88
@@ -95,7 +96,7 @@ def list_box_names():
95
96
even if the `Vagrant.box_list()` implementation is broken.
96
97
"""
97
98
listing = compat .decode (
98
- subprocess .check_output ("vagrant box list --machine-readable" , shell = True )
99
+ subprocess .check_output ([ "vagrant" , " box" , " list" , " --machine-readable"] )
99
100
)
100
101
box_names = []
101
102
for line in listing .splitlines ():
@@ -128,7 +129,7 @@ def fixture_vm_dir(request: FixtureRequest, test_dir) -> Generator[str, None, No
128
129
# It is not an error if a VM has already been destroyed.
129
130
try :
130
131
# Try to destroy any vagrant box that might be running.
131
- subprocess .check_call ("vagrant destroy -f" , cwd = test_dir , shell = True )
132
+ subprocess .check_call ([ "vagrant" , " destroy" , " -f"] , cwd = test_dir )
132
133
except subprocess .CalledProcessError :
133
134
pass
134
135
finally :
@@ -245,20 +246,20 @@ def test_vm_status(vm_dir):
245
246
assert (
246
247
v .NOT_CREATED == v .status ()[0 ].state
247
248
), "Before going up status should be vagrant.NOT_CREATED"
248
- command = "vagrant up"
249
- subprocess .check_call (command , cwd = vm_dir , shell = True )
249
+ command = [ "vagrant" , " up"]
250
+ subprocess .check_call (command , cwd = vm_dir )
250
251
assert (
251
252
v .RUNNING in v .status ()[0 ].state
252
253
), "After going up status should be vagrant.RUNNING"
253
254
254
- command = "vagrant halt"
255
- subprocess .check_call (command , cwd = vm_dir , shell = True )
255
+ command = [ "vagrant" , " halt"]
256
+ subprocess .check_call (command , cwd = vm_dir )
256
257
assert (
257
258
v .POWEROFF in v .status ()[0 ].state
258
259
), "After halting status should be vagrant.POWEROFF"
259
260
260
- command = "vagrant destroy -f"
261
- subprocess .check_call (command , cwd = vm_dir , shell = True )
261
+ command = [ "vagrant" , " destroy" , " -f"]
262
+ subprocess .check_call (command , cwd = vm_dir )
262
263
assert (
263
264
v .NOT_CREATED in v .status ()[0 ].state
264
265
), "After destroying status should be vagrant.NOT_CREATED"
@@ -296,8 +297,8 @@ def test_vm_config(vm_dir):
296
297
"""
297
298
v = vagrant .Vagrant (vm_dir )
298
299
v .up ()
299
- command = "vagrant ssh-config"
300
- ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir , shell = True ))
300
+ command = [ "vagrant" , " ssh-config"]
301
+ ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir ))
301
302
parsed_config = dict (
302
303
line .strip ().split (None , 1 )
303
304
for line in ssh_config .splitlines ()
@@ -536,8 +537,8 @@ def test_multivm_config(vm_dir):
536
537
"""
537
538
v = vagrant .Vagrant (vm_dir , quiet_stdout = False , quiet_stderr = False )
538
539
v .up (vm_name = VM_1 )
539
- command = "vagrant ssh-config " + VM_1
540
- ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir , shell = True ))
540
+ command = [ "vagrant" , " ssh-config" , VM_1 ]
541
+ ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir ))
541
542
parsed_config = dict (
542
543
line .strip ().split (None , 1 )
543
544
for line in ssh_config .splitlines ()
0 commit comments