From b6c4203f85dba18074971208c0602c5bada90e8b Mon Sep 17 00:00:00 2001
From: amitmi704 <36094800+amitmi704@users.noreply.github.com>
Date: Sun, 7 Feb 2021 18:54:27 -0600
Subject: [PATCH] Add hash capabilities to OUI (#225)

Closes #224
---
 netaddr/eui/__init__.py       | 3 +++
 netaddr/tests/eui/test_eui.py | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/netaddr/eui/__init__.py b/netaddr/eui/__init__.py
index 5639676..07bbdc3 100644
--- a/netaddr/eui/__init__.py
+++ b/netaddr/eui/__init__.py
@@ -100,6 +100,9 @@ class OUI(BaseIdentifier):
         else:
             raise NotRegisteredError('OUI %r not registered!' % (oui,))
 
+    def __hash__(self):
+        return hash(self._value)
+
     def __eq__(self, other):
         if not isinstance(other, OUI):
             try:
diff --git a/netaddr/tests/eui/test_eui.py b/netaddr/tests/eui/test_eui.py
index 645a518..c17d0ce 100644
--- a/netaddr/tests/eui/test_eui.py
+++ b/netaddr/tests/eui/test_eui.py
@@ -186,6 +186,14 @@ def test_oui_constructor():
     assert oui.reg_count == 3
 
 
+def test_oui_hash():
+    oui0 = OUI(0)
+    oui1 = OUI(1)
+    oui_dict = {oui0: None, oui1: None}
+
+    assert list(oui_dict.keys()) == [OUI(0), OUI(1)]
+
+
 def test_eui_iab():
     mac = EUI('00-50-C2-00-0F-01')
     assert mac.is_iab()
-- 
2.42.0.windows.2

