Files
shelfmark/tests/download/test_fs_run_blocking_io.py
T
Alex 7d992c3918 User DB cleanup and refactor (#686)
- Refactored user and request code to avoid any database conflicts
- Fix threading behavior with custom script execution
- Harden the no_auth activity user filtering
- Add a hint to add local admin if none is created
- Added secret key to persist login states across updates / restarts
2026-03-02 15:41:15 +00:00

52 lines
1.2 KiB
Python

from __future__ import annotations
import subprocess
import sys
import textwrap
from pathlib import Path
import pytest
def test_run_blocking_io_handles_gevent_patched_subprocess_run() -> None:
pytest.importorskip("gevent")
repo_root = Path(__file__).resolve().parents[2]
script = textwrap.dedent(
"""
import os
import subprocess
import sys
import tempfile
from gevent import monkey
monkey.patch_all()
os.environ.setdefault("LOG_ROOT", tempfile.mkdtemp(prefix="shelfmark-log-root-"))
from shelfmark.download.fs import run_blocking_io
result = run_blocking_io(
subprocess.run,
[sys.executable, "-c", "print('ok')"],
check=True,
capture_output=True,
text=True,
)
assert result.stdout.strip() == "ok"
"""
)
completed = subprocess.run(
[sys.executable, "-c", script],
cwd=str(repo_root),
capture_output=True,
text=True,
)
assert completed.returncode == 0, (
f"Subprocess failed with exit code {completed.returncode}\n"
f"stdout:\n{completed.stdout}\n"
f"stderr:\n{completed.stderr}"
)