diff --git a/src/canmatrix/canmatrix.py b/src/canmatrix/canmatrix.py index 594c3707..87d18fc3 100644 --- a/src/canmatrix/canmatrix.py +++ b/src/canmatrix/canmatrix.py @@ -1321,6 +1321,7 @@ def update_receiver(self): # type: () -> None """ Collect Frame receivers out of receiver given in each signal. Add them to `self.receiver` list. """ + self.receivers = [] for sig in self.signals: for receiver in sig.receivers: self.add_receiver(receiver) diff --git a/tests/test_canmatrix.py b/tests/test_canmatrix.py index f6d774fe..bc8e77aa 100644 --- a/tests/test_canmatrix.py +++ b/tests/test_canmatrix.py @@ -987,6 +987,21 @@ def test_canmatrix_rename_ecu_by_wrong_name(empty_matrix): assert ecu.name == "old_name" +def test_canmatrix_rename_ecu_check_frame(empty_matrix): + ecu = canmatrix.Ecu(name="old_name") + frame = canmatrix.Frame(name="test_frame") + signal = canmatrix.Signal(name="test_signal") + signal.add_receiver("old_name") + frame.add_signal(signal) + frame.update_receiver() + assert "old_name" in frame.receivers + + empty_matrix.add_ecu(ecu) + empty_matrix.add_frame(frame) + empty_matrix.rename_ecu("old_name", "new_name") + assert "old_name" not in frame.receivers + assert "new_name" in frame.receivers + def test_canmatrix_rename_ecu_by_instance(empty_matrix): ecu = canmatrix.Ecu(name="old_name") empty_matrix.add_ecu(ecu)