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