papi: enhance MACAddress() equality
Allows for comparison without needing str(MACAddress())
Traceback (most recent call last):
File "/vpp/test/test_ip6.py", line 1074, in test_icmpv6_echo
self.assertEqual(ether.dst, self.pg0.remote_mac)
AssertionError: '02:01:00:00:ff:02' != MACAddress(02:01:00:00:ff:02)
Type: feature
@@ -54,7 +54,13 @@ class MACAddress():
return '%s(%s)' % (self.__class__.__name__, self.mac_string)
def __eq__(self, other):
+
if not isinstance(other, MACAddress):
+ try:
+ # if it looks like a mac address, we'll take it.
+ # (allows for equality with scapy hw-addresses)
+ return self.mac_binary == MACAddress(other).mac_binary
+ except Exception:
return NotImplemented
return self.mac_binary == other.mac_binary
