tests: Extend build_wsc_attr() to accept both bytes and str objects

This is needed for python3.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2019-02-04 01:48:43 +02:00
parent 786ce912ce
commit b7da11fd95

View file

@ -6227,7 +6227,8 @@ def recv_wsc_msg(dev, opcode, msg_type):
return msg, msg['wsc_attrs'], msg['raw_attrs']
def build_wsc_attr(attr, payload):
return struct.pack('>HH', attr, len(payload)) + payload
_payload = payload if type(payload) == bytes else payload.encode()
return struct.pack('>HH', attr, len(_payload)) + _payload
def build_attr_msg_type(msg_type):
return build_wsc_attr(ATTR_MSG_TYPE, struct.pack('B', msg_type))