Use bytearray.fromhex instead of binascii.unhexlify.
This commit is contained in:
parent
18c82a0592
commit
bd9bbdfd97
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import binascii
|
|
||||||
import mock
|
import mock
|
||||||
import netifaces
|
import netifaces
|
||||||
import struct
|
import struct
|
||||||
@ -30,8 +29,7 @@ class DHCPUtilsTests(unittest.TestCase):
|
|||||||
def test_get_dhcp_request_data(self):
|
def test_get_dhcp_request_data(self):
|
||||||
|
|
||||||
fake_mac_address = '010203040506'
|
fake_mac_address = '010203040506'
|
||||||
fake_mac_address_a = fake_mac_address.encode('ascii', 'strict')
|
fake_mac_address_b = bytearray.fromhex(fake_mac_address)
|
||||||
fake_mac_address_b = bytearray(binascii.unhexlify(fake_mac_address_a))
|
|
||||||
|
|
||||||
data = b'\x01'
|
data = b'\x01'
|
||||||
data += b'\x01'
|
data += b'\x01'
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import binascii
|
|
||||||
import datetime
|
import datetime
|
||||||
import netifaces
|
import netifaces
|
||||||
import random
|
import random
|
||||||
@ -34,9 +33,7 @@ LOG = logging.getLogger(__name__)
|
|||||||
def _get_dhcp_request_data(id_req, mac_address, requested_options,
|
def _get_dhcp_request_data(id_req, mac_address, requested_options,
|
||||||
vendor_id):
|
vendor_id):
|
||||||
|
|
||||||
mac_address_ascii = mac_address.replace(':', '').encode('ascii', 'strict')
|
mac_address_b = bytearray.fromhex(mac_address.replace(':', ''))
|
||||||
mac_address_b = bytearray(binascii.unhexlify(mac_address_ascii))
|
|
||||||
|
|
||||||
# See: http://www.ietf.org/rfc/rfc2131.txt
|
# See: http://www.ietf.org/rfc/rfc2131.txt
|
||||||
data = b'\x01'
|
data = b'\x01'
|
||||||
data += b'\x01'
|
data += b'\x01'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user