@@ -75,15 +75,16 @@ def fixture_test_dir() -> Generator[str, None, None]:
75
75
sys .stderr .write ("test temp dir: {}\n " .format (my_dir ))
76
76
boxes = list_box_names ()
77
77
if TEST_BOX_NAME not in boxes :
78
- cmd = f" { VAGRANT_EXE } box add --provider { TEST_PROVIDER } { TEST_BOX_URL } "
79
- subprocess .check_call (cmd , shell = True )
78
+ cmd = [ VAGRANT_EXE , " box" , " add" , " --provider" , TEST_PROVIDER , TEST_BOX_URL ]
79
+ subprocess .check_call (cmd )
80
80
81
81
yield my_dir
82
82
# Removes the directory created initially, runs once after the last test
83
83
sys .stderr .write ("module teardown()\n " )
84
84
if my_dir is not None :
85
85
try :
86
- subprocess .check_call ("vagrant destroy -f" , cwd = my_dir , shell = True )
86
+ cmd = [VAGRANT_EXE , "destroy" , "-f" ]
87
+ subprocess .check_call (cmd , cwd = my_dir )
87
88
except subprocess .CalledProcessError :
88
89
pass
89
90
@@ -97,9 +98,7 @@ def list_box_names():
97
98
even if the `Vagrant.box_list()` implementation is broken.
98
99
"""
99
100
listing = compat .decode (
100
- subprocess .check_output (
101
- f"{ VAGRANT_EXE } box list --machine-readable" , shell = True
102
- )
101
+ subprocess .check_output ([VAGRANT_EXE , "box" , "list" , "--machine-readable" ])
103
102
)
104
103
box_names = []
105
104
for line in listing .splitlines ():
@@ -132,7 +131,7 @@ def fixture_vm_dir(request: FixtureRequest, test_dir) -> Generator[str, None, No
132
131
# It is not an error if a VM has already been destroyed.
133
132
try :
134
133
# Try to destroy any vagrant box that might be running.
135
- subprocess .check_call (f" { VAGRANT_EXE } destroy -f" , cwd = test_dir , shell = True )
134
+ subprocess .check_call ([ VAGRANT_EXE , " destroy" , " -f"] , cwd = test_dir )
136
135
except subprocess .CalledProcessError :
137
136
pass
138
137
finally :
@@ -249,20 +248,20 @@ def test_vm_status(vm_dir):
249
248
assert (
250
249
v .NOT_CREATED == v .status ()[0 ].state
251
250
), "Before going up status should be vagrant.NOT_CREATED"
252
- command = f" { VAGRANT_EXE } up"
253
- subprocess .check_call (command , cwd = vm_dir , shell = True )
251
+ command = [ VAGRANT_EXE , " up"]
252
+ subprocess .check_call (command , cwd = vm_dir )
254
253
assert (
255
254
v .RUNNING in v .status ()[0 ].state
256
255
), "After going up status should be vagrant.RUNNING"
257
256
258
- command = f" { VAGRANT_EXE } halt"
259
- subprocess .check_call (command , cwd = vm_dir , shell = True )
257
+ command = [ VAGRANT_EXE , " halt"]
258
+ subprocess .check_call (command , cwd = vm_dir )
260
259
assert (
261
260
v .POWEROFF in v .status ()[0 ].state
262
261
), "After halting status should be vagrant.POWEROFF"
263
262
264
- command = f" { VAGRANT_EXE } destroy -f"
265
- subprocess .check_call (command , cwd = vm_dir , shell = True )
263
+ command = [ VAGRANT_EXE , " destroy" , " -f"]
264
+ subprocess .check_call (command , cwd = vm_dir )
266
265
assert (
267
266
v .NOT_CREATED in v .status ()[0 ].state
268
267
), "After destroying status should be vagrant.NOT_CREATED"
@@ -308,8 +307,8 @@ def test_vm_config(vm_dir):
308
307
"""
309
308
v = vagrant .Vagrant (vm_dir )
310
309
v .up ()
311
- command = f" { VAGRANT_EXE } ssh-config"
312
- ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir , shell = True ))
310
+ command = [ VAGRANT_EXE , " ssh-config"]
311
+ ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir ))
313
312
parsed_config = dict (
314
313
line .strip ().split (None , 1 )
315
314
for line in ssh_config .splitlines ()
@@ -548,8 +547,8 @@ def test_multivm_config(vm_dir):
548
547
"""
549
548
v = vagrant .Vagrant (vm_dir , quiet_stdout = False , quiet_stderr = False )
550
549
v .up (vm_name = VM_1 )
551
- command = f" { VAGRANT_EXE } ssh-config " + VM_1
552
- ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir , shell = True ))
550
+ command = [ VAGRANT_EXE , " ssh-config" , VM_1 ]
551
+ ssh_config = compat .decode (subprocess .check_output (command , cwd = vm_dir ))
553
552
parsed_config = dict (
554
553
line .strip ().split (None , 1 )
555
554
for line in ssh_config .splitlines ()
0 commit comments