def copy_events_over(objects, timestamp, execution_events): copied_objects = [] copied_side_effects = [] def side_effects_of(obj): return older_than(side_effects_that_affect_object(execution_events, obj), timestamp) for obj in objects: copied_objects.append(obj) copied_side_effects.extend(side_effects_of(obj)) return copied_objects, copied_side_effects
def copy_events_over(objects, timestamp, execution_events): copied_objects = [] copied_side_effects = [] def side_effects_of(obj): return older_than( side_effects_that_affect_object(execution_events, obj), timestamp) for obj in objects: copied_objects.append(obj) copied_side_effects.extend(side_effects_of(obj)) return copied_objects, copied_side_effects
def include_requirements(test_events, execution_events): ignored_side_effects = side_effects_of(explicit_calls(test_events)) ignored_objects = [] new_events = [] for event in test_events: for new_event in objects_required_for(event, event.timestamp, execution_events): # If a call appears explicitly in the test body we should # ignore all side effects caused by it. if new_event not in ignored_side_effects: new_events.append(new_event) elif isinstance(new_event, AttributeRebind) and not isinstance(new_event.value, ImmutableObject): change = BindingChange(ObjectAttributeReference(new_event.obj, new_event.name, new_event.timestamp), new_event.value, new_event.timestamp) new_events.append(change) # We can ignore the object that already has an assigned name, # unless it was needed earlier. if new_event.value not in new_events: ignored_objects.append(new_event.value) return filter(lambda e: e not in ignored_objects, new_events + test_events)
def include_requirements(test_events, execution_events): ignored_side_effects = side_effects_of(explicit_calls(test_events)) ignored_objects = [] new_events = [] for event in test_events: for new_event in objects_required_for(event, event.timestamp, execution_events): # If a call appears explicitly in the test body we should # ignore all side effects caused by it. if new_event not in ignored_side_effects: new_events.append(new_event) elif isinstance(new_event, AttributeRebind) and not isinstance( new_event.value, ImmutableObject): change = BindingChange( ObjectAttributeReference(new_event.obj, new_event.name, new_event.timestamp), new_event.value, new_event.timestamp) new_events.append(change) # We can ignore the object that already has an assigned name, # unless it was needed earlier. if new_event.value not in new_events: ignored_objects.append(new_event.value) return [e for e in new_events + test_events if e not in ignored_objects]