Unfortunately, I'm not sure what you are talking about is possible. I would say that you can use a decorator, but that would be useless without a complete redefinition. I'm not sure if this is the best for you, but can you just override the method for your tests in your class? That would make it a lot cleaner and you could group your code in a more intuitive way.
do something like:
class DirectClass: def __init__(self): self.data_groups = dict self.consumers_list = list def direct(self): """ routes data in self.data_groups to consumers in self.consumers_list """ for data_type, group in self.data_groups.items(): for consumer_name in self.consumers_list[data_type]: for record in group: consumer = self.get_consumer(consumer_name, record) consumer_output = consumer.do_something() return True class TestDirect(DirectClass): def __init__(self): DirectClass.__init__(self) def direct(self): output_list = [] for data_type, group in self.data_groups.items(): output_list.append(data_type) output_list.append(group) for consumer_name in self.consumers_list[data_type]: for record in group: output_list.append(record.values()[0]) return output_list
user2916286
source share