auto-t: remove hwsim rules on __del__

This prevents previous tests rules from carrying over into
future tests.
This commit is contained in:
James Prestwood 2020-09-11 11:11:29 -07:00 committed by Denis Kenzior
parent 5df28473cb
commit 5b94c9d243
1 changed files with 7 additions and 0 deletions

View File

@ -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