From 5b94c9d2436924216aa94fd452e3b8b97027df9d Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Fri, 11 Sep 2020 11:11:29 -0700 Subject: [PATCH] auto-t: remove hwsim rules on __del__ This prevents previous tests rules from carrying over into future tests. --- autotests/util/hwsim.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/autotests/util/hwsim.py b/autotests/util/hwsim.py index a0ddedcd..cf1ab536 100755 --- a/autotests/util/hwsim.py +++ b/autotests/util/hwsim.py @@ -240,6 +240,9 @@ class RadioList(collections.Mapping): def __delitem__(self, key): self._dict.pop(key).remove() + def values(self): + return self._dict.values() + def _interfaces_added_handler(self, path, interfaces): self._dict[path] = Radio(interfaces[HWSIM_RADIO_INTERFACE]) @@ -271,6 +274,10 @@ class Hwsim(iwd.AsyncOpAbstract): self._rules = RuleSet(self, objects) self._radios = RadioList(self, objects) + def __del__(self): + for rule in self._rules.values(): + rule.remove() + @property def rules(self): return self._rules