From ef9f709e91324c7864443dbf7e50d5d292728e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduard=20Br=C3=B6cker?= Date: Fri, 12 Jul 2024 10:00:22 +0200 Subject: [PATCH] should fix issue #760 (#807) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Eduard Bröcker --- src/canmatrix/canmatrix.py | 1 + tests/test_canmatrix.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) 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)