Use bytearray.fromhex instead of binascii.unhexlify.

This commit is contained in:
Claudiu Popa 2014-09-10 03:21:00 +03:00
parent 18c82a0592
commit bd9bbdfd97
2 changed files with 2 additions and 7 deletions

View File

@ -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'

View File

@ -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'