test_clean_imports.py
1 """ 2 test_clean_imports.py - Test the clean dreamtalk.py import syntax (Phase 6) 3 4 This tests the canonical import pattern: 5 6 from DreamTalk.dreamtalk import * 7 8 Which provides clean, philosophical naming for all core DreamTalk concepts. 9 """ 10 11 # Clear DreamTalk modules to ensure fresh code 12 import sys 13 modules_to_delete = [key for key in sys.modules.keys() if 'DreamTalk' in key] 14 for mod in modules_to_delete: 15 del sys.modules[mod] 16 17 # The canonical import - clean and readable 18 from DreamTalk.dreamtalk import * 19 20 21 class PulsingOrb(Holon): 22 """ 23 A simple holon demonstrating the canonical syntax. 24 25 All imports come from the clean dreamtalk module: 26 - Holon for the base class 27 - Completion for the parameter type 28 - Circle for geometry 29 - State for state machine 30 """ 31 32 # Type-hinted parameter 33 pulse: Completion = 0.5 34 35 # State machine 36 class States: 37 expanded = State(pulse=1.0) 38 contracted = State(pulse=0.2) 39 40 def specify_parts(self): 41 # Inline binding with >> syntax 42 self.orb = Circle(radius=self.pulse_parameter >> 50, color=BLUE) 43 self.parts = [self.orb] 44 45 46 class CleanImportTest(Dream): 47 """Test the clean import syntax with a full scene.""" 48 49 def unfold(self): 50 # Create the holon 51 orb = PulsingOrb() 52 53 # Use state machine 54 self.play(orb.transition_to(PulsingOrb.States.expanded), run_time=1) 55 self.play(orb.transition_to(PulsingOrb.States.contracted), run_time=1) 56 57 # Use fluent animation 58 self.play(orb.animate.pulse(0.5), run_time=0.5) 59 60 self.wait(0.5) 61 62 63 if __name__ == "__main__": 64 CleanImportTest()