MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / create_plugin_files

Function create_plugin_files

tests/python/test_plugin_concurrency.py:21–56  ·  view source on GitHub ↗

Create a minimal plugin with optional artificial delay in on_load.

(plugin_dir: Path, name: str, delay: float = 0.0)

Source from the content-addressed store, hash-verified

19
20
21def create_plugin_files(plugin_dir: Path, name: str, delay: float = 0.0):
22 """Create a minimal plugin with optional artificial delay in on_load."""
23 plugin_dir.mkdir(exist_ok=True)
24
25 (plugin_dir / "pyproject.toml").write_text(
26 f"""
27[project]
28name = "{name}"
29version = "1.0.0"
30description = ""
31
32[tool.lichtfeld]
33auto_start = false
34hot_reload = true
35plugin_api = ">=1,<2"
36lichtfeld_version = ">=0.4.2"
37required_features = []
38"""
39 )
40
41 delay_code = f"import time; time.sleep({delay})" if delay > 0 else ""
42 (plugin_dir / "__init__.py").write_text(
43 f"""
44LOAD_COUNT = 0
45UNLOAD_COUNT = 0
46
47def on_load():
48 global LOAD_COUNT
49 {delay_code}
50 LOAD_COUNT += 1
51
52def on_unload():
53 global UNLOAD_COUNT
54 UNLOAD_COUNT += 1
55"""
56 )
57
58
59@pytest.fixture

Calls

no outgoing calls

Tested by

no test coverage detected