def test_record_container(self): container = RecordContainer() # add records for i in range(7): container.record(SentinelRecord()) self.assertEqual(len(container._records), 7) # save records container.save_to_file(self.filename) with open(self.filename, "r") as handle: lines = handle.readlines() self.assertEqual(lines, ["\n"] * 7)
def test_change_event_recorder(self): test_object = TestObject() container = RecordContainer() recorder = ChangeEventRecorder(container=container) trait_notifiers.set_change_event_tracers( pre_tracer=recorder.pre_tracer, post_tracer=recorder.post_tracer) try: test_object.number = 5.0 finally: trait_notifiers.clear_change_event_tracers() filename = os.path.join(self.directory, 'MainThread.trace') container.save_to_file(filename) with open(filename, 'r') as handle: lines = handle.readlines() self.assertEqual(len(lines), 4) # very basic checking self.assertTrue( "-> 'number' changed from 2.0 to 5.0 in 'TestObject'\n" in lines[0]) self.assertTrue('CALLING' in lines[1]) self.assertTrue('EXIT' in lines[2])
def test_change_event_recorder(self): test_object = TestObject() container = RecordContainer() recorder = ChangeEventRecorder(container=container) trait_notifiers.set_change_event_tracers( pre_tracer=recorder.pre_tracer, post_tracer=recorder.post_tracer) try: test_object.number = 5.0 finally: trait_notifiers.clear_change_event_tracers() filename = os.path.join(self.directory, 'MainThread.trace') container.save_to_file(filename) with open(filename, 'Ur') as handle: lines = handle.readlines() self.assertEqual(len(lines), 4) # very basic checking self.assertTrue( "-> 'number' changed from 2.0 to 5.0 in 'TestObject'\n" in lines[0]) self.assertTrue('CALLING' in lines[1]) self.assertTrue('EXIT' in lines[2])
def test_record_container(self): container = RecordContainer() # add records for i in range(7): container.record(SentinelRecord()) self.assertEqual(len(container._records), 7) # save records container.save_to_file(self.filename) with open(self.filename, 'r') as handle: lines = handle.readlines() self.assertEqual(lines, ['\n'] * 7)