aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vpp-api/python/vpp_papi/macaddress.py11
-rw-r--r--src/vpp-api/python/vpp_papi/tests/test_macaddress.py10
2 files changed, 21 insertions, 0 deletions
diff --git a/src/vpp-api/python/vpp_papi/macaddress.py b/src/vpp-api/python/vpp_papi/macaddress.py
index a1003812003..5005fa8d92e 100644
--- a/src/vpp-api/python/vpp_papi/macaddress.py
+++ b/src/vpp-api/python/vpp_papi/macaddress.py
@@ -52,3 +52,14 @@ class MACAddress():
def __repr__(self):
return '%s(%s)' % (self.__class__.__name__, self.mac_string)
+
+ def __eq__(self, other):
+ if not isinstance(other, MACAddress):
+ return NotImplemented
+ return self.mac_binary == other.mac_binary
+
+ def __ne__(self, other):
+ return not self == other
+
+ def __hash__(self):
+ return hash(self.mac_binary)
diff --git a/src/vpp-api/python/vpp_papi/tests/test_macaddress.py b/src/vpp-api/python/vpp_papi/tests/test_macaddress.py
new file mode 100644
index 00000000000..08e365afd92
--- /dev/null
+++ b/src/vpp-api/python/vpp_papi/tests/test_macaddress.py
@@ -0,0 +1,10 @@
+import unittest
+from vpp_papi import MACAddress
+
+
+class TestMacAddress(unittest.TestCase):
+
+ def test_eq(self):
+ mac = '11:22:33:44:55:66'
+ self.assertEqual(MACAddress(mac),
+ MACAddress(mac))