Skip to content

Commit ab32260

Browse files
authored
improve some python tests (f3d-app#2657)
1 parent ab407a1 commit ab32260

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

python/testing/test_camera.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,15 @@ def test_state_init():
9292

9393

9494
@pytest.mark.xfail(reason="CameraState equality not implemented")
95-
def test_state_compare():
95+
def test_state_compare_eq():
9696
state1 = f3d.CameraState((1, 2, 3), (1, 22, 3), (0, 0, 1), 32)
9797
state2 = f3d.CameraState((1, 2, 3), (1, 22, 3), (0, 0, 1), 32)
9898
assert state1 == state2
9999

100+
101+
@pytest.mark.xfail(reason="CameraState equality not implemented")
102+
def test_state_compare_neq():
103+
state1 = f3d.CameraState((1, 2, 3), (1, 22, 3), (0, 0, 1), 32)
100104
state3 = f3d.CameraState((1, 2, 3), (1, 22, 3), (0, 0, 1), 25)
101105
assert state1 != state3
102106

python/testing/test_engine.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import f3d
66

77

8-
@pytest.fixture
98
def test_plugins_list():
109
base_dir = Path(f3d.__file__).parent
1110
plugins = f3d.Engine.get_plugins_list(base_dir / "share/f3d/plugins")

python/testing/test_interactor.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,30 @@ def test_command(capfd: pytest.CaptureFixture[str]):
4444
inter.add_command("my_cmd2", print_fn, ("my_cmd2", "doc"), compl_fn)
4545

4646

47+
def test_command_completion(capfd: pytest.CaptureFixture[str]):
48+
engine = f3d.Engine.create(True)
49+
inter = engine.interactor
50+
51+
# Check default commands can be removed
52+
actions = inter.get_command_actions()
53+
for action in actions:
54+
inter.remove_command(action)
55+
assert len(inter.get_command_actions()) == 0
56+
57+
# Smoke test
58+
inter.init_commands()
59+
inter.add_command("cmd", print_fn, ("cmd", "doc"), compl_fn)
60+
61+
engine.window.render()
62+
63+
inter.trigger_keyboard_key(inter.InputAction.PRESS, "Escape")
64+
inter.trigger_keyboard_key(inter.InputAction.RELEASE, "Escape")
65+
for c in "cmd ":
66+
inter.trigger_text_character(ord(c))
67+
inter.trigger_keyboard_key(inter.InputAction.PRESS, "Tab")
68+
inter.trigger_keyboard_key(inter.InputAction.RELEASE, "Tab")
69+
70+
4771
def test_binding():
4872
engine = f3d.Engine.create(True)
4973
inter = engine.interactor

0 commit comments

Comments
 (0)