<commit_before>=IEEE EUI-64 Tests=

Copyright (c) 2008-2015, <NAME>. All rights reserved.

{{{

>>> from netaddr import *

}}}

IEEE EUI-64 tests.

{{{

>>> eui = EUI('00-1B-77-FF-FE-49-54-FD')
>>> eui
EUI('00-1B-77-FF-FE-49-54-FD')

>>> eui.oui
OUI('00-1B-77')

>>> eui.ei
'FF-FE-49-54-FD'

>>> eui.eui64()
EUI('00-1B-77-FF-FE-49-54-FD')

>>> mac = EUI('00-0F-1F-12-E7-33')
>>> ip = mac.ipv6_link_local()
>>> ip
IPAddress('fe80::20f:1fff:fe12:e733')
>>> ip.is_link_local()
True

>>> mac.eui64()
EUI('00-0F-1F-FF-FE-12-E7-33')

}}}

Individual Address Block tests.

{{{

>>> lower_eui = EUI('00-50-C2-05-C0-00')
>>> upper_eui = EUI('00-50-C2-05-CF-FF')

>>> lower_eui.is_iab()
True

>>> str(lower_eui.oui)
'00-50-C2'

>>> str(lower_eui.iab)
'00-50-C2-05-C0-00'

>>> lower_eui.ei
'05-C0-00'

>>> int(lower_eui.oui) == 0x0050c2
True

>>> int(lower_eui.iab) == 0x0050c205c
True

>>> upper_eui.is_iab()
True

>>> str(upper_eui.oui)
'00-50-C2'

>>> str(upper_eui.iab)
'00-50-C2-05-C0-00'

>>> upper_eui.ei
'05-CF-FF'

>>> int(upper_eui.oui) == 0x0050c2
True

>>> int(upper_eui.iab) == 0x0050c205c
True

}}}

Constructor tests.

{{{

>>> eui = EUI('00-90-96-AF-CC-39')

>>> eui == EUI('0-90-96-AF-CC-39')
True

>>> eui == EUI('00-90-96-af-cc-39')
True

>>> eui == EUI('00:90:96:AF:CC:39')
True

>>> eui == EUI('00:90:96:af:cc:39')
True

>>> eui == EUI('0090-96AF-CC39')
True

>>> eui == EUI('0090:96af:cc39')
True

>>> eui == EUI('009096-AFCC39')
True

>>> eui == EUI('009096:AFCC39')
True

>>> eui == EUI('009096AFCC39')
True

>>> eui == EUI('009096afcc39')
True

>>> EUI('01-00-00-00-00-00') == EUI('010000000000')
True

>>> EUI('01-00-00-00-00-00') == EUI('10000000000')
True

>>> EUI('01-00-00-01-00-00') == EUI('010000:010000')
True

>>> EUI('01-00-00-01-00-00') == EUI('10000:10000')
True

}}}

EUI-48 and EUI-64 indentifiers of the same value are *not* equivalent.

{{{

>>> eui48 = EUI('01-00-00-01-00-00')
>>> int(eui48) == 1099511693312
True

>>> eui64 = EUI('00-00-01-00-00-01-00-00')
>>> int(eui64) == 1099511693312
True

>>> eui48 == eui64
False

}}}
 
Sortability

{{{

>>> import random

>>> eui_list = [EUI(0, 64), EUI(0), EUI(0xffffffffffff, dialect=mac_unix), EUI(0x1000000000000)]

>>> random.shuffle(eui_list)

>>> eui_list.sort()

>>> for eui in eui_list:
... 	str(eui), eui.version
('00-00-00-00-00-00', 48)
('ff:ff:ff:ff:ff:ff', 48)
('00-00-00-00-00-00-00-00', 64)
('00-01-00-00-00-00-00-00', 64)

}}}
<commit_msg>Add tests for new __eq__ functionality, also test subclassing<commit_after>=IEEE EUI-64 Tests=

Copyright (c) 2008-2015, <NAME>. All rights reserved.

{{{

>>> from netaddr import *

}}}

IEEE EUI-64 tests.

{{{

>>> eui = EUI('00-1B-77-FF-FE-49-54-FD')
>>> eui
EUI('00-1B-77-FF-FE-49-54-FD')

>>> eui.oui
OUI('00-1B-77')

>>> eui.ei
'FF-FE-49-54-FD'

>>> eui.eui64()
EUI('00-1B-77-FF-FE-49-54-FD')

>>> mac = EUI('00-0F-1F-12-E7-33')
>>> ip = mac.ipv6_link_local()
>>> ip
IPAddress('fe80::20f:1fff:fe12:e733')
>>> ip.is_link_local()
True

>>> mac.eui64()
EUI('00-0F-1F-FF-FE-12-E7-33')

}}}

Individual Address Block tests.

{{{

>>> lower_eui = EUI('00-50-C2-05-C0-00')
>>> upper_eui = EUI('00-50-C2-05-CF-FF')

>>> lower_eui.is_iab()
True

>>> str(lower_eui.oui)
'00-50-C2'

>>> str(lower_eui.iab)
'00-50-C2-05-C0-00'

>>> lower_eui.ei
'05-C0-00'

>>> int(lower_eui.oui) == 0x0050c2
True

>>> int(lower_eui.iab) == 0x0050c205c
True

>>> upper_eui.is_iab()
True

>>> str(upper_eui.oui)
'00-50-C2'

>>> str(upper_eui.iab)
'00-50-C2-05-C0-00'

>>> upper_eui.ei
'05-CF-FF'

>>> int(upper_eui.oui) == 0x0050c2
True

>>> int(upper_eui.iab) == 0x0050c205c
True

}}}

Constructor tests.

{{{

>>> eui = EUI('00-90-96-AF-CC-39')

>>> eui == EUI('0-90-96-AF-CC-39')
True

>>> eui == EUI('00-90-96-af-cc-39')
True

>>> eui == EUI('00:90:96:AF:CC:39')
True

>>> eui == EUI('00:90:96:af:cc:39')
True

>>> eui == EUI('0090-96AF-CC39')
True

>>> eui == EUI('0090:96af:cc39')
True

>>> eui == EUI('009096-AFCC39')
True

>>> eui == EUI('009096:AFCC39')
True

>>> eui == EUI('009096AFCC39')
True

>>> eui == EUI('009096afcc39')
True

>>> EUI('01-00-00-00-00-00') == EUI('010000000000')
True

>>> EUI('01-00-00-00-00-00') == EUI('10000000000')
True

>>> EUI('01-00-00-01-00-00') == EUI('010000:010000')
True

>>> EUI('01-00-00-01-00-00') == EUI('10000:10000')
True

}}}

EUI-48 and EUI-64 indentifiers of the same value are *not* equivalent.

{{{

>>> eui48 = EUI('01-00-00-01-00-00')
>>> int(eui48) == 1099511693312
True

>>> eui64 = EUI('00-00-01-00-00-01-00-00')
>>> int(eui64) == 1099511693312
True

>>> eui48 == eui64
False

}}}

Equality check for EUI must support subclassing

{{{
>>> eui = EUI(42)
>>> class MySubclass(EUI): pass
>>> my_instance = MySubclass(42)
>>> my_instance2 = MySubclass(43)
>>> class YourSubclass(EUI): pass
>>> your_instance = YourSubclass(42)
>>> your_instance2 = YourSubclass(43)

>>> eui == my_instance
True

>>> eui == my_instance2
False

>>> my_instance == your_instance
True

>>> my_instance == your_instance2
False

>>> my_instance != your_instance2
True

}}}

Equality check for OUI must support subclassing

{{{
>>> oui = OUI('00-1B-77')
>>> class MySubclass(OUI): pass
>>> my_instance = MySubclass('00-1B-77')
>>> my_instance2 = MySubclass('00-1B-78')
>>> class YourSubclass(OUI): pass
>>> your_instance = YourSubclass('00-1B-77')
>>> your_instance2 = YourSubclass('00-1B-78')

>>> oui == my_instance
True

>>> oui == my_instance2
False

>>> my_instance == your_instance
True

>>> my_instance == your_instance2
False

>>> my_instance != your_instance2
True

}}}

Equality check for IAB must support subclassing

{{{
>>> iab = IAB('00-50-C2-00-00-00')
>>> class MySubclass(IAB): pass
>>> my_instance = MySubclass('00-50-C2-00-00-00')
>>> my_instance2 = MySubclass('00-50-C2-99-00-00')
>>> class YourSubclass(IAB): pass
>>> your_instance = YourSubclass('00-50-C2-00-00-00')
>>> your_instance2 = YourSubclass('00-50-C2-99-00-00')

>>> iab == my_instance
True

>>> iab == my_instance2
False

>>> my_instance == your_instance
True

>>> my_instance == your_instance2
False

>>> my_instance != your_instance2
True

}}}

Check equality between EUI objects and their textual representations

{{{

>>> eui = EUI('11-22-33-44-55-66')
>>> class MySubclass(EUI): pass
>>> my_instance = MySubclass('11-22-33-44-55-66')

>>> eui == '11-22-33-44-55-66'
True

>>> my_instance == '11-22-33-44-55-66'
True

>>> my_instance == '99-22-33-44-55-66'
False

}}}

Check equality between OUI objects and their textual representations

{{{

>>> oui = OUI('00-1B-77')
>>> class MySubclass(OUI): pass
>>> my_instance = MySubclass('00-1B-77')

>>> oui == '00-1B-77'
True

>>> my_instance == '00-1B-77'
True

>>> my_instance == '00-1B-99'
False

}}}

Check equality between IAB objects and their textual representations
{{{

>>> eui = IAB('00-50-C2-00-00-00')
>>> class MySubclass(IAB): pass
>>> my_instance = MySubclass('00-50-C2-00-00-00')

>>> eui == '00-50-C2-00-00-00'
True

>>> my_instance == '00-50-C2-00-00-00'
True

>>> my_instance == '00-50-C2-99-00-00'
False

}}}
 
Sortability

{{{

>>> import random

>>> eui_list = [EUI(0, 64), EUI(0), EUI(0xffffffffffff, dialect=mac_unix), EUI(0x1000000000000)]

>>> random.shuffle(eui_list)

>>> eui_list.sort()

>>> for eui in eui_list:
... 	str(eui), eui.version
('00-00-00-00-00-00', 48)
('ff:ff:ff:ff:ff:ff', 48)
('00-00-00-00-00-00-00-00', 64)
('00-01-00-00-00-00-00-00', 64)

}}}

{'fraction_non_alphanumeric': 0.2436837815810921, 'fraction_numerical': 0.1647650095082858, 'mean_word_length': 4.113194444444445, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 467, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 8, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3803619', 'n_tokens_mistral': 4134, 'n_tokens_neox': 3467, 'n_words': 533}