Converts tests from Timer-based async patterns to step()-based sync patterns, eliminating timeout issues in headless testing. Refactored tests: - simple_timer_screenshot_test.py - test_animation_callback_simple.py - test_animation_property_locking.py - test_animation_raii.py - test_animation_removal.py - test_timer_callback.py Also updates KNOWN_ISSUES.md with comprehensive documentation on the step()-based testing pattern including examples and best practices. 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test timer callback arguments with new Timer API (#173)
|
|
Uses mcrfpy.step() for synchronous test execution.
|
|
"""
|
|
import mcrfpy
|
|
import sys
|
|
|
|
call_count = 0
|
|
|
|
def new_style_callback(timer, runtime):
|
|
"""New style callback - receives timer object and runtime"""
|
|
global call_count
|
|
call_count += 1
|
|
print(f"Callback called with: timer={timer} (type: {type(timer)}), runtime={runtime} (type: {type(runtime)})")
|
|
if hasattr(timer, 'once'):
|
|
print(f"Got Timer object! once={timer.once}")
|
|
|
|
# Set up the scene
|
|
test_scene = mcrfpy.Scene("test_scene")
|
|
test_scene.activate()
|
|
|
|
print("Testing new Timer callback signature (timer, runtime)...")
|
|
timer = mcrfpy.Timer("test_timer", new_style_callback, 100)
|
|
print(f"Timer created: {timer}")
|
|
|
|
# Advance time to let timer fire - each step() processes timers once
|
|
mcrfpy.step(0.15) # First fire
|
|
mcrfpy.step(0.15) # Second fire
|
|
|
|
if call_count >= 2:
|
|
print("PASS: Timer callback received correct arguments")
|
|
sys.exit(0)
|
|
else:
|
|
print(f"FAIL: Expected at least 2 callbacks, got {call_count}")
|
|
sys.exit(1)
|