35 lines
965 B
Python
35 lines
965 B
Python
"""Regression tests for Kivy-free reusable core modules."""
|
|
|
|
import importlib
|
|
import builtins
|
|
|
|
|
|
CORE_MODULES = (
|
|
"katrain.core.base_katrain",
|
|
"katrain.core.lang",
|
|
"katrain.core.game_node",
|
|
"katrain.core.engine",
|
|
"katrain.core.game",
|
|
"katrain.core.remote_engine",
|
|
"katrain.core.contribute_engine",
|
|
)
|
|
|
|
|
|
def test_core_imports_without_kivy(monkeypatch):
|
|
original_import = builtins.__import__
|
|
|
|
def reject_kivy(name, *args, **kwargs):
|
|
if name == "kivy" or name.startswith("kivy."):
|
|
raise AssertionError(f"core imported Kivy: {name}")
|
|
return original_import(name, *args, **kwargs)
|
|
|
|
monkeypatch.setattr(builtins, "__import__", reject_kivy)
|
|
for module in CORE_MODULES:
|
|
importlib.reload(importlib.import_module(module))
|
|
|
|
|
|
def test_pv_text_has_no_frontend_markup():
|
|
from katrain.core.game_node import GameNode
|
|
|
|
assert GameNode().make_pv("B", ["D4", "Q16"], interactive=True) == "BD4 Q16"
|