Skip to content

Commit b3aefbe

Browse files
committed
fix(tests): fiabilise test_workspace en tmp et supprime la dépréciation locale
1 parent af27948 commit b3aefbe

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

Core/i18n.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,16 @@ async def normalize_lang_pref(pref: str | None) -> str:
143143

144144
def _resolve_system_language_sync() -> str:
145145
try:
146-
loc = locale.getdefaultlocale()[0] or ""
146+
# Python 3.15+: avoid deprecated locale.getdefaultlocale().
147+
loc = (locale.getlocale()[0] or "").strip()
148+
if not loc:
149+
# Fallback env-based locale resolution for non-initialized locale contexts.
150+
loc = (
151+
os.environ.get("LC_ALL")
152+
or os.environ.get("LC_MESSAGES")
153+
or os.environ.get("LANG")
154+
or ""
155+
).strip()
147156
return "fr" if loc.lower().startswith(("fr", "fr_")) else "en"
148157
except Exception:
149158
return "en"

tests/conftest.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,20 @@
2929

3030
@pytest.fixture()
3131
def test_workspace(tmp_path: Path) -> Path:
32-
"""Return a temporary copy of tests/workspace_for_test for file operations."""
32+
"""Return a temporary workspace for file-operation tests.
33+
34+
The fixture prefers copying `tests/workspace_for_test` when available.
35+
If that template folder is missing, it creates a minimal workspace in
36+
`tmp_path` so tests remain hermetic and portable.
37+
"""
3338
src = Path(__file__).parent / "workspace_for_test"
3439
dest = tmp_path / "workspace"
35-
shutil.copytree(src, dest)
40+
if src.exists():
41+
shutil.copytree(src, dest)
42+
return dest
43+
44+
dest.mkdir(parents=True, exist_ok=True)
45+
(dest / "main.py").write_text("print('hello from test workspace')\n", encoding="utf-8")
46+
(dest / "requirements.txt").write_text("requests\n", encoding="utf-8")
47+
(dest / ".ark").mkdir(parents=True, exist_ok=True)
3648
return dest

0 commit comments

Comments
 (0)