13class ReturnTrueFalse(basf2.Module):
18 self.event_counter = 0
21 self.return_value(int(self.event_counter % 3))
22 self.event_counter += 1
25class Counter(basf2.Module):
39counter_end = Counter()
41counter_path_0 = basf2.create_path()
42counter_path_0.add_module(counter_0)
43counter_path_1 = basf2.create_path()
44counter_path_1.add_module(counter_1)
45counter_path_2 = basf2.create_path()
46counter_path_2.add_module(counter_2)
48path = basf2.create_path()
49path.add_module(
"EventInfoSetter", evtNumList=[3])
51module_with_conditions = path.add_module(ReturnTrueFalse())
52module_with_conditions.if_value(
"=0", counter_path_0)
53module_with_conditions.if_value(
"=1", counter_path_1)
54module_with_conditions.if_value(
"=2", counter_path_2, basf2.AfterConditionPath.CONTINUE)
56path.add_module(counter_end)
60assert counter_0.counter == 1
61assert counter_1.counter == 1
62assert counter_2.counter == 1
63assert counter_end.counter == 1