Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix: 注入运行时库清单与 heredoc 禁令,放行 SVG 文本读取

renquanjia5504aa36e1d3
diff --git a/jiuwenswarm/agents/harness/common/prompt/shell_environment.py b/jiuwenswarm/agents/harness/common/prompt/shell_environment.py
index 20c8dbe233..86843055e7 100644
--- a/jiuwenswarm/agents/harness/common/prompt/shell_environment.py
+++ b/jiuwenswarm/agents/harness/common/prompt/shell_environment.py
@@ -3,11 +3,82 @@
from __future__ import annotations
+import importlib.util
import os
import shutil
+from functools import lru_cache
from pathlib import Path
from typing import Iterable, Optional
+# 场景常用库:(展示标签, import 名, 包名)。
+# 只做 find_spec 探测,不真正 import;未命中的一律不出现在提示词里,
+# 避免在依赖不同的部署环境里给出"写了但没装"的错误承诺。
+# 注意:xlrd / pypdf 不在标准部署的直接依赖内,标准部署下恒不渲染;
+# 保留是为了覆盖预装了更多库的发行形态。
+_LIB_CANDIDATES: tuple[tuple[str, str, str], ...] = (
+ ("Word", "docx", "python-docx"),
+ ("Excel", "openpyxl", "openpyxl"),
+ ("Excel (.xls)", "xlrd", "xlrd"),
+ ("Excel 写图表", "xlsxwriter", "XlsxWriter"),
+ ("数据处理", "pandas", "pandas"),
+ ("PPT", "pptx", "python-pptx"),
+ ("PDF", "pypdf", "pypdf"),
+ ("PDF", "pdfplumber", "pdfplumber"),
+ ("图片", "PIL", "Pillow"),
+ ("XML/HTML", "lxml", "lxml"),
+)
+
+_PDF_FALLBACK_MODULES: tuple[str, ...] = ("pypdf", "pdfplumber")
+
+
+def _spec_available(module: str) -> bool:
+ try:
+ return importlib.util.find_spec(module) is not None
+ except Exception: # noqa: BLE001 — 探测位于提示词热路径,任何异常都不得中断构建
+ return False
+
+
+@lru_cache(maxsize=2)
+def build_python_library_prompt(language: str) -> str:
+ """List Python libraries located via importlib spec probing (cached per process)."""
+ found = [
+ (label, module, package)
+ for label, module, package in _LIB_CANDIDATES
+ if _spec_available(module)
+ ]
+ fitz_available = _spec_available("fitz")
+ # 兜底建议必须来自真实探测,不能无条件承诺未安装的库。
+ pdf_fallbacks = [package for _label, module, package in found if module in _PDF_FALLBACK_MODULES]
+
+ if language == "cn":
+ lines = ["Python 库(运行时探测,仅列已探测到的):"]
+ lines.extend(f"- {label}:{package}(import {module})" for label, module, package in found)
+ if fitz_available:
+ lines.append("- PDF:PyMuPDF 可用(import fitz)")
+ elif pdf_fallbacks:
+ lines.append(f"- PDF:未探测到 fitz/PyMuPDF,改用 {' 或 '.join(pdf_fallbacks)}")
+ else:
+ lines.append("- PDF:未探测到 fitz/PyMuPDF、pypdf、pdfplumber,按实际 import 结果选择")
+ if found:
+ lines.append("以上为已探测到的库;其余以实际 import 结果为准,失败再改用上方清单。")
+ else:
+ lines.append("未探测到预置的常用库;以实际 import 结果为准,缺失时先安装再使用。")
+ return "\n".join(lines)
+
+ lines = ["Python libraries (runtime probe; detected only):"]
+ lines.extend(f"- {label}: {package} (import {module})" for label, module, package in found)
+ if fitz_available:
+ lines.append("- PDF: PyMuPDF available (import fitz)")
+ elif pdf_fallbacks:
+ lines.append(f"- PDF: fitz/PyMuPDF not detected; use {' or '.join(pdf_fallbacks)}")
+ else:
+ lines.append("- PDF: none of fitz/PyMuPDF, pypdf, pdfplumber detected; trust the actual import result")
+ if found:
+ lines.append("The list above was detected in this runtime; for anything else trust the actual import result.")
+ else:
+ lines.append("No preset Office library detected; trust the actual import result and install what is missing.")
+ return "\n".join(lines)
+
def _is_wsl_bash_path(path: str) -> bool:
normalized = path.replace("/", "\\").lower()
@@ -114,13 +185,35 @@ def _path_bash_status(language: str, path: Optional[str]) -> str:
return f"可用,路径 `{path}`" if language == "cn" else f"available at `{path}`"
-def build_shell_environment_prompt(language: str, os_type: str) -> str:
+def _build_shell_core(language: str, os_type: str) -> str:
"""Return shell capability and selection guidance for the current host."""
path_bash = shutil.which("bash")
if os_type.startswith("win"):
powershell = _available_powershell()
git_bash = _available_git_bash()
+ if git_bash:
+ heredoc_cn = (
+ "- heredoc 仅在 bash/Git Bash 中使用;PowerShell/cmd 不支持,"
+ "其 here-string `@\"...\"@` 会展开变量。\n"
+ " 写文件优先用 write_file,改文件用 edit_file。"
+ )
+ heredoc_en = (
+ "- Use heredocs only in bash/Git Bash; PowerShell/cmd does not support them, "
+ "and its here-string `@\"...\"@` expands variables.\n"
+ " Prefer write_file to create files and edit_file to modify them."
+ )
+ else:
+ heredoc_cn = (
+ "- 不要用 heredoc 写文件(`cat <<EOF`、`<<'EOF'`):当前没有可用的 Git Bash,"
+ "PowerShell/cmd 不支持;\n"
+ " 其 here-string `@\"...\"@` 还会展开变量。写文件用 write_file,改文件用 edit_file。"
+ )
+ heredoc_en = (
+ "- Do not write files with heredocs (`cat <<EOF`, `<<'EOF'`): no Git Bash is available, "
+ "PowerShell/cmd does not support them,\n"
+ " and its here-string `@\"...\"@` expands variables. Use write_file and edit_file instead."
+ )
if language == "cn":
return f"""Shell 能力:
- PowerShell:{_status(language, powershell)}
@@ -130,7 +223,8 @@ def build_shell_environment_prompt(language: str, os_type: str) -> str:
Shell 选择规则:
- Windows 且 Git Bash 可用,或 PATH bash 明确不是 WSL stub 时,可以使用 bash/Git Bash 执行 POSIX 命令,例如 `ls`、`grep`、`cat`、`mkdir -p`、bash 脚本。
- Windows 且 Git Bash 不可用、PATH bash 也不可用或只是 WSL stub 时,不要使用 POSIX 命令;优先使用 PowerShell 或 cmd。
-- PowerShell cmdlet 不要包在 bash 里执行,应直接使用 PowerShell。"""
+- PowerShell cmdlet 不要包在 bash 里执行,应直接使用 PowerShell。
+{heredoc_cn}"""
return f"""Shell capabilities:
- PowerShell: {_status(language, powershell)}
- Git Bash: {_status(language, git_bash)}
@@ -139,7 +233,8 @@ Shell 选择规则:
Shell selection rules:
- On Windows, when Git Bash is available, or PATH bash is clearly not a WSL stub, use bash/Git Bash for POSIX commands such as `ls`, `grep`, `cat`, `mkdir -p`, and bash scripts.
- On Windows, when Git Bash is unavailable and PATH bash is unavailable or only a WSL stub, do not use POSIX commands; prefer PowerShell or cmd.
-- Do not wrap PowerShell cmdlets in bash; invoke PowerShell directly."""
+- Do not wrap PowerShell cmdlets in bash; invoke PowerShell directly.
+{heredoc_en}"""
shell_path = shutil.which("bash") or shutil.which("sh")
if language == "cn":
@@ -155,3 +250,18 @@ Shell 选择规则:
Shell selection rules:
- Linux/macOS usually use bash/sh-style commands.
- If bash/sh is unavailable, use the current platform's available shell or dedicated tools."""
+
+
+def build_shell_environment_prompt(
+ language: str, os_type: str, *, include_libraries: bool = True
+) -> str:
+ """Return shell guidance, optionally followed by the runtime library list.
+
+ The list belongs to the static identity section. Callers that append a
+ second env section to the same system prompt pass ``include_libraries=False``
+ when the identity section already carries it, so it is emitted exactly once.
+ """
+ core = _build_shell_core(language, os_type)
+ if not include_libraries:
+ return core
+ return f"{core}\n\n{build_python_library_prompt(language)}"
diff --git a/jiuwenswarm/agents/harness/common/rails/read_file_validation.py b/jiuwenswarm/agents/harness/common/rails/read_file_validation.py
index 441eb072d6..082b772ff5 100644
--- a/jiuwenswarm/agents/harness/common/rails/read_file_validation.py
+++ b/jiuwenswarm/agents/harness/common/rails/read_file_validation.py
@@ -35,7 +35,6 @@ _IMAGE_EXTENSIONS = frozenset(
".webp",
".tiff",
".tif",
- ".svg",
".ico",
".heic",
".heif",
diff --git a/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py b/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py
index afd11e0a67..f692b0c27c 100644
--- a/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py
+++ b/jiuwenswarm/agents/harness/common/rails/runtime_prompt_rail.py
@@ -37,6 +37,30 @@ from jiuwenswarm.common.utils import (
_LANGUAGE_NAMES = {"cn": "Chinese (Simplified)", "zh": "Chinese (Simplified)", "en": "English"}
+_LIBRARY_LIST_MARKERS = ("运行时探测", "runtime probe")
+
+
+def _prompt_has_library_list(builder: Any) -> bool:
+ """Return True when *builder* already carries the runtime library list.
+
+ The list lives in the static identity section, which is absent for agents
+ that build their prompt elsewhere (e.g. code mode). The env section must
+ add it only in that case, otherwise the same list is injected twice.
+ """
+ get_section = getattr(builder, "get_section", None)
+ if not callable(get_section):
+ return False
+ try:
+ section = get_section("identity")
+ except Exception: # noqa: BLE001 — 诊断能力缺失时按「没有」处理,宁可多注入一份
+ return False
+ content = getattr(section, "content", None)
+ texts = content.values() if isinstance(content, dict) else [content]
+ return any(
+ isinstance(text, str) and any(marker in text for marker in _LIBRARY_LIST_MARKERS)
+ for text in texts
+ )
+
class RuntimePromptRail(DeepAgentRail):
"""在 before_model_call 中注入时间及运行时状态文件路径。"""
@@ -490,7 +514,13 @@ class RuntimePromptRail(DeepAgentRail):
import platform as plat
os_version = f"{plat.system()} {plat.release()}"
env_language = "cn" if not self._force_english and self._language == "cn" else "en"
- shell_env_prompt = build_shell_environment_prompt(env_language, os_type)
+ # 库清单由静态 identity 段注入;这里只在 identity 缺失时补一份,
+ # 避免同一份清单在同一 system prompt 里出现两次。
+ shell_env_prompt = build_shell_environment_prompt(
+ env_language,
+ os_type,
+ include_libraries=not _prompt_has_library_list(self.system_prompt_builder),
+ )
if not self._force_english and self._language == "cn":
env_content = (
diff --git a/jiuwenswarm/agents/harness/common/tools/command_tools.py b/jiuwenswarm/agents/harness/common/tools/command_tools.py
index 3fd5d4ec1e..6103198bb7 100644
--- a/jiuwenswarm/agents/harness/common/tools/command_tools.py
+++ b/jiuwenswarm/agents/harness/common/tools/command_tools.py
@@ -14,6 +14,7 @@ import re
import shlex
import shutil
import subprocess
+import sys
import time
from pathlib import Path
from typing import Any, Sequence
@@ -765,6 +766,17 @@ def _path_key(env: dict[str, str]) -> str:
return "PATH"
+def _runtime_python_dir() -> str | None:
+ """Return the directory of the running interpreter, if it ships ``python.exe``.
+ """
+ if not sys.executable:
+ return None
+ exe_dir = os.path.dirname(os.path.abspath(sys.executable))
+ if os.path.isfile(os.path.join(exe_dir, "python.exe")):
+ return exe_dir
+ return None
+
+
def _discover_windows_tool_dirs() -> tuple[list[str], list[str]]:
"""Discover tool dirs to merge into subprocess PATH (Windows only).
@@ -781,6 +793,14 @@ def _discover_windows_tool_dirs() -> tuple[list[str], list[str]]:
"""
trusted: list[str] = []
workspace: list[str] = []
+
+ # Custom install roots (e.g. D:\Application\OfficeAce) are invisible to the
+ # default-root scan below. Reuse the running interpreter's directory so the
+ # subprocess gets the same Python that the prompt probed.
+ runtime_python_dir = _runtime_python_dir()
+ if runtime_python_dir:
+ trusted.append(runtime_python_dir)
+
local_app_data = os.environ.get("LOCALAPPDATA")
program_files = os.environ.get("ProgramFiles")
program_files_root = (
diff --git a/jiuwenswarm/resources/config.yaml b/jiuwenswarm/resources/config.yaml
index 2b31c570c1..09d915f54e 100644
--- a/jiuwenswarm/resources/config.yaml
+++ b/jiuwenswarm/resources/config.yaml
@@ -677,6 +677,7 @@ react:
- external_memory_search
enable_for_models: # 模型白名单(空=全部启用)
- glm
+ - deepseek
subagents: # 子 agent 延迟加载配置
enabled: false # 子 agent 总开关,默认关闭
inherit_parent_eager_tools: true # 继承父 agent 的 eager 列表
diff --git a/tests/unit_tests/agents/harness/common/prompt/test_shell_environment.py b/tests/unit_tests/agents/harness/common/prompt/test_shell_environment.py
new file mode 100644
index 0000000000..b6574ef291
--- /dev/null
+++ b/tests/unit_tests/agents/harness/common/prompt/test_shell_environment.py
@@ -0,0 +1,128 @@
+# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
+
+"""shell_environment:运行时库探测、双语文案与 heredoc 条件化。"""
+
+from __future__ import annotations
+
+import pytest
+
+from jiuwenswarm.agents.harness.common.prompt import shell_environment as se
+from jiuwenswarm.agents.harness.common.rails import runtime_prompt_rail as rpr
+
+
[email protected](autouse=True)
+def _clear_library_cache():
+ se.build_python_library_prompt.cache_clear()
+ yield
+ se.build_python_library_prompt.cache_clear()
+
+
+def _patch_probes(monkeypatch: pytest.MonkeyPatch, available: set[str]) -> None:
+ monkeypatch.setattr(se, "_spec_available", lambda module: module in available)
+
+
+def _patch_windows_shells(
+ monkeypatch: pytest.MonkeyPatch, git_bash: str | None
+) -> None:
+ monkeypatch.setattr(se.shutil, "which", lambda _name: None)
+ monkeypatch.setattr(se, "_available_powershell", lambda: "powershell.exe")
+ monkeypatch.setattr(se, "_available_git_bash", lambda: git_bash)
+
+
+def test_spec_available_probes_real_modules() -> None:
+ assert se._spec_available("json") is True
+ assert se._spec_available("definitely_not_a_module_xyz") is False
+
+
+def test_cn_lists_only_detected_libraries(monkeypatch: pytest.MonkeyPatch) -> None:
+ _patch_probes(monkeypatch, {"docx", "openpyxl", "fitz"})
+
+ text = se.build_python_library_prompt("cn")
+
+ assert "python-docx" in text
+ assert "openpyxl" in text
+ assert "PyMuPDF 可用" in text
+ assert "pandas" not in text
+
+
+def test_cn_fitz_missing_recommends_only_detected_fallbacks(monkeypatch: pytest.MonkeyPatch) -> None:
+ """CR-1:兜底建议必须来自探测结果,不能无条件推荐 pypdf/pdfplumber。"""
+ _patch_probes(monkeypatch, {"docx", "pypdf"})
+
+ text = se.build_python_library_prompt("cn")
+
+ assert "改用 pypdf" in text
+ assert "pdfplumber" not in text
+
+
+def test_cn_nothing_detected_makes_no_promise(monkeypatch: pytest.MonkeyPatch) -> None:
+ _patch_probes(monkeypatch, set())
+
+ text = se.build_python_library_prompt("cn")
+
+ assert "未探测到 fitz/PyMuPDF、pypdf、pdfplumber" in text
+ assert "未探测到预置的常用库" in text
+ assert "改用" not in text
+
+
+def test_en_empty_probe_is_self_consistent(monkeypatch: pytest.MonkeyPatch) -> None:
+ _patch_probes(monkeypatch, set())
+
+ text = se.build_python_library_prompt("en")
+
+ assert "No preset Office library detected" in text
+ assert "list above" not in text
+
+
+def test_shell_prompt_can_drop_library_list(monkeypatch: pytest.MonkeyPatch) -> None:
+ """CR-4:库清单只走一条注入链路,运行时链路可显式关闭。"""
+ _patch_probes(monkeypatch, {"docx"})
+ _patch_windows_shells(monkeypatch, git_bash=None)
+
+ with_libs = se.build_shell_environment_prompt("cn", "win32")
+ without_libs = se.build_shell_environment_prompt("cn", "win32", include_libraries=False)
+
+ assert "python-docx" in with_libs
+ assert "python-docx" not in without_libs
+ assert "Shell 能力" in without_libs
+
+
+def test_heredoc_rule_follows_git_bash_availability(monkeypatch: pytest.MonkeyPatch) -> None:
+ """CR-5:有 Git Bash 时不应一刀切禁止 heredoc。"""
+ _patch_windows_shells(monkeypatch, git_bash=None)
+ assert "不要用 heredoc 写文件" in se.build_shell_environment_prompt("cn", "win32")
+
+ _patch_windows_shells(monkeypatch, git_bash="C:/Git/bin/bash.exe")
+ text = se.build_shell_environment_prompt("cn", "win32")
+
+ assert "heredoc 仅在 bash/Git Bash 中使用" in text
+ assert "不要用 heredoc 写文件" not in text
+
+
+class _FakeSection:
+ def __init__(self, content: object) -> None:
+ self.content = content
+
+
+class _FakeBuilder:
+ def __init__(self, sections: dict[str, _FakeSection]) -> None:
+ self._sections = sections
+
+ def get_section(self, name: str) -> _FakeSection | None:
+ return self._sections.get(name)
+
+
+def test_identity_section_keeps_library_list(monkeypatch: pytest.MonkeyPatch) -> None:
+ """CR-4:identity 已带清单时,运行时链路不再重复注入。"""
+ _patch_probes(monkeypatch, {"docx"})
+ builder = _FakeBuilder({
+ "identity": _FakeSection({"cn": "…… Python 库(运行时探测,仅列已探测到的): python-docx ……"}),
+ })
+
+ assert rpr._prompt_has_library_list(builder) is True
+
+
+def test_missing_identity_section_lets_env_section_add_list() -> None:
+ """code 模式没有 identity 段,运行时链路必须补注入。"""
+ assert rpr._prompt_has_library_list(_FakeBuilder({})) is False
+ assert rpr._prompt_has_library_list(object()) is False
diff --git a/tests/unit_tests/agents/harness/common/rails/test_read_file_validation.py b/tests/unit_tests/agents/harness/common/rails/test_read_file_validation.py
index da06fb0b92..e77b38af88 100644
--- a/tests/unit_tests/agents/harness/common/rails/test_read_file_validation.py
+++ b/tests/unit_tests/agents/harness/common/rails/test_read_file_validation.py
@@ -7,9 +7,19 @@ from __future__ import annotations
from openjiuwen.harness.tools.base_tool import ToolOutput
from jiuwenswarm.agents.harness.common.rails.read_file_validation import (
+ _looks_like_binary_payload,
+ is_image_file_path,
+ is_non_text_file_path,
validate_read_file_result,
)
+_SVG_WITH_BASE64 = (
+ '<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8">'
+ '<image href="data:image/png;base64,'
+ "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
+ '/></svg>'
+)
+
def _multi_file_output(content_a: str, content_b: str) -> ToolOutput:
return ToolOutput(
@@ -110,3 +120,26 @@ def test_empty_result_still_rejected() -> None:
ok, _error = validate_read_file_result("a.txt", "")
assert ok is False
+
+
+def test_svg_is_read_as_text_not_image() -> None:
+ """SVG 是文本 XML:前置拦截与后置校验都不应把它当图片。"""
+ assert is_image_file_path("diagram.svg") is False
+ assert is_non_text_file_path("diagram.svg") is False
+
+
+def test_svg_with_embedded_base64_passes_validation() -> None:
+ """内嵌 base64 图片的合法 SVG 不得被二进制启发式误拦。"""
+ assert _looks_like_binary_payload(_SVG_WITH_BASE64) is False
+ assert validate_read_file_result("diagram.svg", _SVG_WITH_BASE64) == (True, None)
+
+
+def test_image_extensions_still_blocked() -> None:
+ """防误扩大:位图扩展名仍按图片/二进制拦截。"""
+ assert is_image_file_path("photo.png") is True
+ assert is_non_text_file_path("photo.jpg") is True
+
+ ok, error = validate_read_file_result("photo.png", "\x00\x01binary")
+
+ assert ok is False
+ assert error is not None
diff --git a/tests/unit_tests/agents/test_command_tools_posix_windows.py b/tests/unit_tests/agents/test_command_tools_posix_windows.py
index 6a01a8fe74..27a7058f71 100644
--- a/tests/unit_tests/agents/test_command_tools_posix_windows.py
+++ b/tests/unit_tests/agents/test_command_tools_posix_windows.py
@@ -3,9 +3,11 @@
from __future__ import annotations
import os
+from pathlib import Path
import pytest
+from jiuwenswarm.agents.harness.common.tools import command_tools
from jiuwenswarm.agents.harness.common.tools.command_tools import (
_looks_like_posix,
_resolve_execution_plan,
@@ -15,6 +17,8 @@ from jiuwenswarm.agents.harness.common.tools.command_tools import (
_translate_posix_segment_for_powershell,
_available_bash,
_available_powershell,
+ _build_subprocess_env,
+ _runtime_python_dir,
)
@@ -219,3 +223,45 @@ class TestResolveExecutionPlanNonWindows:
def test_auto_routes_to_bash(self) -> None:
plan, use_shell, resolved_shell = _resolve_execution_plan("mkdir -p dir", "auto")
assert resolved_shell in ("bash", "sh")
+
+
+# ── _runtime_python_dir / Windows PATH hardening ────────────────────
+
+
+class TestRuntimePythonDir:
+ def test_custom_install_root_from_executable(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ """自定义盘安装(D:\\Application\\OfficeAce)由 sys.executable 直接解析。"""
+ python_dir = tmp_path / "tools" / "python"
+ python_dir.mkdir(parents=True)
+ (python_dir / "python.exe").write_bytes(b"")
+ monkeypatch.setattr(command_tools.sys, "executable", str(python_dir / "python.exe"))
+
+ assert _runtime_python_dir() == str(python_dir)
+
+ def test_venv_scripts_layout(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ scripts = tmp_path / "venv" / "Scripts"
+ scripts.mkdir(parents=True)
+ (scripts / "python.exe").write_bytes(b"")
+ monkeypatch.setattr(command_tools.sys, "executable", str(scripts / "python.exe"))
+
+ assert _runtime_python_dir() == str(scripts)
+
+ def test_skips_directory_without_python_exe(self, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
+ """冻结入口(同级没有 python.exe)不得向 PATH 注入无效目录。"""
+ exe_dir = tmp_path / "OfficeAce"
+ exe_dir.mkdir()
+ monkeypatch.setattr(command_tools.sys, "executable", str(exe_dir / "OfficeAce.exe"))
+
+ assert _runtime_python_dir() is None
+
+ def test_returns_none_for_empty_executable(self, monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(command_tools.sys, "executable", "")
+
+ assert _runtime_python_dir() is None
+
+
+class TestWindowsPathHardeningNonWindows:
+ def test_returns_none_on_non_windows(self) -> None:
+ if os.name == "nt":
+ pytest.skip("Non-Windows-only")
+ assert _build_subprocess_env(None) is None