Skip to content

Commit 1d21f2b

Browse files
committed
avoid shell=True
1 parent 8b8994c commit 1d21f2b

File tree

1 file changed

+6
-3
lines changed
  • usr/lib/python3/dist-packages/stdisplay/tests

1 file changed

+6
-3
lines changed

usr/lib/python3/dist-packages/stdisplay/tests/stprint.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
import os
1010
import subprocess
11+
from pathlib import Path
1112
import unittest
1213
from stdisplay.stdisplay import (
1314
get_sgr_support,
@@ -63,12 +64,15 @@ def shell(
6364
"""
6465
test_dir = os.path.dirname(os.path.abspath(__file__))
6566
script_dir = os.path.dirname(test_dir)
66-
command = "../../../../bin/stprint"
67+
stprint_absolute_path = "../../../../bin/stprint"
68+
stprint_absolute_path = str(Path(stprint_absolute_path).resolve())
6769
input_data = ""
6870
if stdin:
71+
command = [stprint_absolute_path]
6972
input_data = text
7073
else:
71-
command += f" '{text}'"
74+
command = [stprint_absolute_path, text]
75+
7276
## Avoid tester environment from affecting tests, such as CI having
7377
## TERM=dumb, but also allow us testing if RegEx is correct
7478
## depending on the terminal provided.
@@ -85,7 +89,6 @@ def shell(
8589
input=input_data,
8690
env=env,
8791
cwd=script_dir,
88-
shell=True,
8992
capture_output=True,
9093
check=True,
9194
text=True,

0 commit comments

Comments
 (0)