mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import sys
|
||||
import time
|
||||
from collections.abc import Callable
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from unshackle.core import binaries
|
||||
from unshackle.core.binaries import binary_version, parse_version, probe_output
|
||||
from unshackle.core.binaries import binary_version, parse_version
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -54,26 +52,3 @@ def test_bare_call_only_for_listed_tools(monkeypatch: pytest.MonkeyPatch) -> Non
|
||||
calls.clear()
|
||||
assert binary_version(Path("/opt/bin/othertool")) is None
|
||||
assert calls == [["--version"], ["-version"]]
|
||||
|
||||
|
||||
def test_timeout_stops_the_probe(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
calls: list[list[str]] = []
|
||||
monkeypatch.setattr(binaries, "probe_output", fake_probe({"--version": None}, calls))
|
||||
|
||||
assert binary_version(Path("/opt/bin/othertool")) is None
|
||||
assert calls == [["--version"]]
|
||||
|
||||
|
||||
def test_timeout_kills_the_whole_tree(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> None:
|
||||
monkeypatch.setattr(binaries, "PROBE_TIMEOUT", 0.5)
|
||||
if sys.platform == "win32":
|
||||
tool = tmp_path / "wrapper.bat"
|
||||
tool.write_text("@echo off\r\nping -n 30 127.0.0.1 >nul\r\n")
|
||||
else:
|
||||
tool = tmp_path / "wrapper"
|
||||
tool.write_text("#!/bin/sh\nsleep 30 &\nsleep 30\n")
|
||||
tool.chmod(0o755)
|
||||
|
||||
start = time.monotonic()
|
||||
assert probe_output(tool, ["--version"]) is None
|
||||
assert time.monotonic() - start < 10
|
||||
|
||||
Reference in New Issue
Block a user