Six fixes. The CHANGELOG has an entry for each. - Queue the legacy ComfyUI update and answer failed version requests - Check out a branch head by its name with GitPython - Follow the update policy when an update request names no version line - Print the messages of manager_core as they are - Refuse a db_mode or update_policy request the servers cannot use - Keep a setting chosen while the legacy menu is loading it The E2E cases wait for the Registry list, which a fresh environment has not cached, and the Playwright cases no longer depend on the timing of the UI.
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""`print` of the two `manager_core` modules writes its text as it is.
|
|
|
|
The cases take what binds the name `print` out of a `manager_core.py`, an
|
|
import or a function, and call it.
|
|
"""
|
|
import ast
|
|
import io
|
|
|
|
import pytest
|
|
|
|
from legacy_html_testutil import PACKAGE
|
|
|
|
|
|
@pytest.fixture(params=["glob", "legacy"])
|
|
def printed(request):
|
|
source = (PACKAGE / request.param / "manager_core.py").read_text(encoding="utf-8")
|
|
nodes = [node for node in ast.parse(source).body
|
|
if isinstance(node, (ast.Import, ast.ImportFrom)) and "rich" in ast.unparse(node)
|
|
or isinstance(node, ast.FunctionDef) and node.name == "print"]
|
|
namespace = {}
|
|
exec(compile(ast.Module(body=nodes, type_ignores=[]), "<manager_core print>", "exec"), namespace)
|
|
|
|
def printed(*objects, **options):
|
|
out = io.StringIO()
|
|
namespace["print"](*objects, file=out, **options)
|
|
return out.getvalue()
|
|
|
|
return printed
|
|
|
|
|
|
@pytest.mark.parametrize("text", [
|
|
"Install(git-clone) error: https://example.com/a[/b] / failed",
|
|
"## ComfyUI-Manager: EXECUTE => ['python', '-m', 'pip', 'install', 'diffusers[torch]']",
|
|
"skip black listed pip installation: 'requests[socks]'",
|
|
"Uninstall: custom_nodes/pack:100:backup",
|
|
"Download: git clone 'https://github.com/" + "a" * 120 + "'",
|
|
], ids=["closing tag", "list with an extra", "extra", "emoji code", "longer than 80 columns"])
|
|
def test_text_is_written_as_it_is(printed, text):
|
|
assert printed(text) == text + "\n"
|
|
|
|
|
|
def test_objects_are_written_as_their_text(printed):
|
|
assert printed("Update error:", ValueError("no section [/x]"), 3) == "Update error: no section [/x] 3\n"
|
|
|
|
|
|
def test_end_and_sep_are_kept(printed):
|
|
assert printed("a", "b", sep="-", end="") == "a-b"
|