Skip to content

Commit 79035c8

Browse files
authored
fix(execution): redirect error messages to stderr and clean up print statements (#25684)
fixes #24743
1 parent be293a9 commit 79035c8

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

python_files/unittestadapter/execution.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,22 +284,21 @@ def send_run_data(raw_data, test_run_pipe):
284284
run_test_ids_pipe = os.environ.get("RUN_TEST_IDS_PIPE")
285285
test_run_pipe = os.getenv("TEST_RUN_PIPE")
286286
if not run_test_ids_pipe:
287-
print("Error[vscode-unittest]: RUN_TEST_IDS_PIPE env var is not set.")
287+
print("Error[vscode-unittest]: RUN_TEST_IDS_PIPE env var is not set.", file=sys.stderr)
288288
raise VSCodeUnittestError("Error[vscode-unittest]: RUN_TEST_IDS_PIPE env var is not set.")
289289
if not test_run_pipe:
290-
print("Error[vscode-unittest]: TEST_RUN_PIPE env var is not set.")
290+
print("Error[vscode-unittest]: TEST_RUN_PIPE env var is not set.", file=sys.stderr)
291291
raise VSCodeUnittestError("Error[vscode-unittest]: TEST_RUN_PIPE env var is not set.")
292292
test_ids = []
293293
cwd = pathlib.Path(start_dir).absolute()
294294
try:
295295
# Read the test ids from the file, attempt to delete file afterwords.
296296
ids_path = pathlib.Path(run_test_ids_pipe)
297297
test_ids = ids_path.read_text(encoding="utf-8").splitlines()
298-
print("Received test ids from temp file.")
299298
try:
300299
ids_path.unlink()
301300
except Exception as e:
302-
print("Error[vscode-pytest]: unable to delete temp file" + str(e))
301+
print(f"Error[vscode-unittest]: unable to delete temp file: {e}", file=sys.stderr)
303302

304303
except Exception as e:
305304
# No test ids received from buffer, return error payload
@@ -318,10 +317,6 @@ def send_run_data(raw_data, test_run_pipe):
318317
is_coverage_run = os.environ.get("COVERAGE_ENABLED") is not None
319318
include_branches = False
320319
if is_coverage_run:
321-
print(
322-
"COVERAGE_ENABLED env var set, starting coverage. workspace_root used as parent dir:",
323-
workspace_root,
324-
)
325320
import coverage
326321

327322
# insert "python_files/lib/python" into the path so packaging can be imported
@@ -350,7 +345,6 @@ def send_run_data(raw_data, test_run_pipe):
350345

351346
# If no error occurred, we will have test ids to run.
352347
if manage_py_path := os.environ.get("MANAGE_PY_PATH"):
353-
print("MANAGE_PY_PATH env var set, running Django test suite.")
354348
args = argv[index + 1 :] or []
355349
django_execution_runner(manage_py_path, test_ids, args)
356350
else:

0 commit comments

Comments
 (0)