From 8ddad8962c41a49e1d9d114ad6c3c1c1793f6cd5 Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Sat, 23 Dec 2023 17:56:35 +0200 Subject: [PATCH] Use f-strings where sensible --- pyproject.toml | 1 + src/paho/mqtt/client.py | 30 ++++++++------- src/paho/mqtt/properties.py | 18 ++++----- src/paho/mqtt/subscribeoptions.py | 2 +- tests/mqtt5_props.py | 6 +-- tests/paho_test.py | 15 ++++---- tests/test_mqttv5.py | 58 ++++++++++++++--------------- tests/test_websocket_integration.py | 10 ++--- 8 files changed, 69 insertions(+), 71 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e7a5fc42..174800d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,6 +79,7 @@ extend-select = [ "F63", "F7", "F82", + "FLY", # flynt "I", "S", # Bandit "UP", diff --git a/src/paho/mqtt/client.py b/src/paho/mqtt/client.py index 5c616186..cde01a9c 100644 --- a/src/paho/mqtt/client.py +++ b/src/paho/mqtt/client.py @@ -338,7 +338,7 @@ def wait_for_publish(self, timeout=None): elif self.rc == MQTT_ERR_AGAIN: pass elif self.rc > 0: - raise RuntimeError('Message publish failed: %s' % (error_string(self.rc))) + raise RuntimeError(f'Message publish failed: {error_string(self.rc)}') timeout_time = None if timeout is None else time_func() + timeout timeout_tenth = None if timeout is None else timeout / 10. @@ -357,7 +357,7 @@ def is_published(self): elif self.rc == MQTT_ERR_AGAIN: pass elif self.rc > 0: - raise RuntimeError('Message publish failed: %s' % (error_string(self.rc))) + raise RuntimeError(f'Message publish failed: {error_string(self.rc)}') with self._condition: return self._published @@ -515,7 +515,7 @@ def __init__(self, client_id="", clean_session=None, userdata=None, if transport.lower() not in ('websockets', 'tcp'): raise ValueError( - 'transport must be "websockets" or "tcp", not %s' % transport) + f'transport must be "websockets" or "tcp", not {transport}') self._manual_ack = manual_ack self._transport = transport.lower() self._protocol = protocol @@ -923,17 +923,17 @@ def connect_srv(self, domain=None, keepalive=60, bind_address="", domain = domain[domain.find('.') + 1:] try: - rr = '_mqtt._tcp.%s' % domain + rr = f'_mqtt._tcp.{domain}' if self._ssl: # IANA specifies secure-mqtt (not mqtts) for port 8883 - rr = '_secure-mqtt._tcp.%s' % domain + rr = f'_secure-mqtt._tcp.{domain}' answers = [] for answer in dns.resolver.query(rr, dns.rdatatype.SRV): addr = answer.target.to_text()[:-1] answers.append( (addr, answer.port, answer.priority, answer.weight)) except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer, dns.resolver.NoNameservers) as err: - raise ValueError("No answer/NXDOMAIN for SRV in %s" % domain) from err + raise ValueError(f"No answer/NXDOMAIN for SRV in {domain}") from err # FIXME: doesn't account for weight for answer in answers: @@ -2808,8 +2808,10 @@ def _send_connect(self, keepalive): proto_ver |= 0x80 self._pack_remaining_length(packet, remaining_length) - packet.extend(struct.pack("!H" + str(len(protocol)) + "sBBH", len(protocol), protocol, proto_ver, connect_flags, - keepalive)) + packet.extend(struct.pack( + f"!H{len(protocol)}sBBH", + len(protocol), protocol, proto_ver, connect_flags, keepalive, + )) if self._protocol == MQTTv5: packet += packed_connect_properties @@ -3273,7 +3275,7 @@ def _handle_disconnect(self): def _handle_suback(self): self._easy_log(MQTT_LOG_DEBUG, "Received SUBACK") - pack_format = "!H" + str(len(self._in_packet['packet']) - 2) + 's' + pack_format = f"!H{len(self._in_packet['packet']) - 2}s" (mid, packet) = struct.unpack(pack_format, self._in_packet['packet']) if self._protocol == MQTTv5: @@ -3283,7 +3285,7 @@ def _handle_suback(self): for c in packet[props_len:]: reasoncodes.append(ReasonCodes(SUBACK >> 4, identifier=c)) else: - pack_format = "!" + "B" * len(packet) + pack_format = f"!{'B' * len(packet)}" granted_qos = struct.unpack(pack_format, packet) with self._callback_mutex: @@ -3315,9 +3317,9 @@ def _handle_publish(self): message.qos = (header & 0x06) >> 1 message.retain = (header & 0x01) - pack_format = "!H" + str(len(self._in_packet['packet']) - 2) + 's' + pack_format = f"!H{len(self._in_packet['packet']) - 2}s" (slen, packet) = struct.unpack(pack_format, self._in_packet['packet']) - pack_format = '!' + str(slen) + 's' + str(len(packet) - slen) + 's' + pack_format = f"!{slen}s{len(packet) - slen}s" (topic, packet) = struct.unpack(pack_format, packet) if self._protocol != MQTTv5 and len(topic) == 0: @@ -3330,12 +3332,12 @@ def _handle_publish(self): try: print_topic = topic.decode('utf-8') except UnicodeDecodeError: - print_topic = "TOPIC WITH INVALID UTF-8: " + str(topic) + print_topic = f"TOPIC WITH INVALID UTF-8: {topic!r}" message.topic = topic if message.qos > 0: - pack_format = "!H" + str(len(packet) - 2) + 's' + pack_format = f"!H{len(packet) - 2}s" (message.mid, packet) = struct.unpack(pack_format, packet) if self._protocol == MQTTv5: diff --git a/src/paho/mqtt/properties.py b/src/paho/mqtt/properties.py index 2a9d08bc..e5e19103 100644 --- a/src/paho/mqtt/properties.py +++ b/src/paho/mqtt/properties.py @@ -259,7 +259,7 @@ def __setattr__(self, name, value): # the name could have spaces in, or not. Remove spaces before assignment if name not in [aname.replace(' ', '') for aname in self.names.keys()]: raise MQTTException( - "Property name must be one of "+str(self.names.keys())) + f"Property name must be one of {self.names.keys()}") # check that this attribute applies to the packet type if self.packetType not in self.properties[self.getIdentFromName(name)][1]: raise MQTTException(f"Property {name} does not apply to packet type {PacketTypes.Names[self.packetType]}") @@ -269,23 +269,20 @@ def __setattr__(self, name, value): if name in ["ReceiveMaximum", "TopicAlias"] \ and (value < 1 or value > 65535): - raise MQTTException( - "%s property value must be in the range 1-65535" % (name)) + raise MQTTException(f"{name} property value must be in the range 1-65535") elif name in ["TopicAliasMaximum"] \ and (value < 0 or value > 65535): - raise MQTTException( - "%s property value must be in the range 0-65535" % (name)) + raise MQTTException(f"{name} property value must be in the range 0-65535") elif name in ["MaximumPacketSize", "SubscriptionIdentifier"] \ and (value < 1 or value > 268435455): - raise MQTTException( - "%s property value must be in the range 1-268435455" % (name)) + raise MQTTException(f"{name} property value must be in the range 1-268435455") elif name in ["RequestResponseInformation", "RequestProblemInformation", "PayloadFormatIndicator"] \ and (value != 0 and value != 1): raise MQTTException( - "%s property value must be 0 or 1" % (name)) + f"{name} property value must be 0 or 1") if self.allowsMultiple(name): if not isinstance(value, list): @@ -302,8 +299,7 @@ def __str__(self): if hasattr(self, compressedName): if not first: buffer += ", " - buffer += compressedName + " : " + \ - str(getattr(self, compressedName)) + buffer += f"{compressedName} : {getattr(self, compressedName)}" first = False buffer += "]" return buffer @@ -422,6 +418,6 @@ def unpack(self, buffer): compressedName = propname.replace(' ', '') if not self.allowsMultiple(compressedName) and hasattr(self, compressedName): raise MQTTException( - "Property '%s' must not exist more than once" % property) + f"Property '{property}' must not exist more than once") setattr(self, propname, value) return self, propslen + VBIlen diff --git a/src/paho/mqtt/subscribeoptions.py b/src/paho/mqtt/subscribeoptions.py index 92154799..f56973ce 100644 --- a/src/paho/mqtt/subscribeoptions.py +++ b/src/paho/mqtt/subscribeoptions.py @@ -63,7 +63,7 @@ def __init__(self, qos=0, noLocal=False, retainAsPublished=False, retainHandling def __setattr__(self, name, value): if name not in self.names: raise MQTTException( - name + " Attribute name must be one of "+str(self.names)) + f"{name} Attribute name must be one of {self.names}") object.__setattr__(self, name, value) def pack(self): diff --git a/tests/mqtt5_props.py b/tests/mqtt5_props.py index 4d612150..f9be0d66 100644 --- a/tests/mqtt5_props.py +++ b/tests/mqtt5_props.py @@ -42,18 +42,18 @@ def gen_uint32_prop(identifier, word): def gen_string_prop(identifier, s): s = s.encode("utf-8") - prop = struct.pack('!BH%ds'%(len(s)), identifier, len(s), s) + prop = struct.pack(f'!BH{len(s)}s', identifier, len(s), s) return prop def gen_string_pair_prop(identifier, s1, s2): s1 = s1.encode("utf-8") s2 = s2.encode("utf-8") - prop = struct.pack('!BH%dsH%ds'%(len(s1), len(s2)), identifier, len(s1), s1, len(s2), s2) + prop = struct.pack(f'!BH{len(s1)}sH{len(s2)}s', identifier, len(s1), s1, len(s2), s2) return prop def gen_varint_prop(identifier, val): v = pack_varint(val) - return struct.pack("!B"+str(len(v))+"s", identifier, v) + return struct.pack(f"!B{len(v)}s", identifier, v) def pack_varint(varint): s = b"" diff --git a/tests/paho_test.py b/tests/paho_test.py index f25c355b..6829adbe 100644 --- a/tests/paho_test.py +++ b/tests/paho_test.py @@ -87,14 +87,13 @@ def expect_packet(sock, name, expected): def packet_matches(name, recvd, expected): if recvd != expected: - print("FAIL: Received incorrect " + name + ".") + print(f"FAIL: Received incorrect {name}.") try: - print("Received: " + to_string(recvd)) + print(f"Received: {to_string(recvd)}") except struct.error: - print("Received (not decoded): 0x" + - binascii.b2a_hex(recvd).decode('utf8')) + print(f"Received (not decoded): 0x{binascii.b2a_hex(recvd).decode('utf8')}") try: - print("Expected: " + to_string(expected)) + print(f"Expected: {to_string(expected)}") except struct.error: print("Expected (not decoded): 0x" + binascii.b2a_hex(expected).decode('utf8')) @@ -163,7 +162,7 @@ def do_client_connect(connect_packet, connack_packet, hostname="localhost", port def remaining_length(packet): l = min(5, len(packet)) # noqa: E741 - all_bytes = struct.unpack("!" + "B" * l, packet[:l]) + all_bytes = struct.unpack(f"!{'B' * l}", packet[:l]) mult = 1 rl = 0 for i in range(1, l - 1): @@ -195,7 +194,7 @@ def to_string(packet): if len(packet) == 0: return "" - packet0 = struct.unpack("!B%ds" % (len(packet)-1), bytes(packet)) + packet0 = struct.unpack(f"!B{len(packet) - 1}s", bytes(packet)) packet0 = packet0[0] cmd = packet0 & 0xF0 if cmd == 0x00: @@ -388,7 +387,7 @@ def mqtt_read_string(sock, rl): slen = sock.recv(2) slen, = struct.unpack("!H", slen) payload = sock.recv(slen) - payload, = struct.unpack("!%ds" % (slen), payload) + payload, = struct.unpack(f"!{slen}s", payload) rl -= (2 + slen) return (payload, rl) diff --git a/tests/test_mqttv5.py b/tests/test_mqttv5.py index b10e5f31..905e3791 100644 --- a/tests/test_mqttv5.py +++ b/tests/test_mqttv5.py @@ -455,7 +455,7 @@ def test_subscribe_failure(self): response = ocallback.wait_subscribed() self.assertEqual(response["reasonCodes"][0].getName(), "Unspecified error", - "return code should be 0x80 %s" % response["reasonCodes"][0].getName()) + f"return code should be 0x80 {response['reasonCodes'][0].getName()}") oclient.disconnect() oclient.loop_stop() @@ -700,7 +700,7 @@ def test_message_expiry(self): connect_properties = Properties(PacketTypes.CONNECT) connect_properties.SessionExpiryInterval = 99999 - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.loop_start() lbclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) response = lbcallback.wait_connected() @@ -712,7 +712,7 @@ def test_message_expiry(self): lbcallback.wait_disconnected() lbclient.loop_stop() - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.loop_start() laclient.connect(host="localhost", port=self._test_broker_port) publish_properties = Properties(PacketTypes.PUBLISH) @@ -730,7 +730,7 @@ def test_message_expiry(self): 2, retain=False, properties=publish_properties) time.sleep(3) - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.loop_start() lbclient.connect(host="localhost", port=self._test_broker_port, clean_start=False) lbcallback.wait_connected() @@ -753,7 +753,7 @@ def test_subscribe_options(self): # noLocal clientid = 'subscribe options - noLocal' - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) lacallback.wait_connected() laclient.loop_start() @@ -761,7 +761,7 @@ def test_subscribe_options(self): topics[0], options=SubscribeOptions(qos=2, noLocal=True)) lacallback.wait_subscribed() - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.connect(host="localhost", port=self._test_broker_port) lbcallback.wait_connected() lbclient.loop_start() @@ -784,7 +784,7 @@ def test_subscribe_options(self): # retainAsPublished clientid = 'subscribe options - retain as published' - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) lacallback.wait_connected() laclient.subscribe(topics[0], options=SubscribeOptions( @@ -808,7 +808,7 @@ def test_subscribe_options(self): # retainHandling clientid = 'subscribe options - retain handling' - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) lacallback.wait_connected() laclient.publish(topics[1], b"qos 0", 0, retain=True) @@ -894,7 +894,7 @@ def test_subscribe_options(self): def test_subscription_identifiers(self): clientid = 'subscription identifiers' - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) lacallback.wait_connected() laclient.loop_start() @@ -904,7 +904,7 @@ def test_subscription_identifiers(self): laclient.subscribe(topics[0], qos=2, properties=sub_properties) lacallback.wait_subscribed() - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.connect(host="localhost", port=self._test_broker_port) lbcallback.wait_connected() lbclient.loop_start() @@ -915,7 +915,7 @@ def test_subscription_identifiers(self): sub_properties.clear() sub_properties.SubscriptionIdentifier = 3 - lbclient.subscribe(topics[0]+"/#", qos=2, properties=sub_properties) + lbclient.subscribe(f"{topics[0]}/#", qos=2, properties=sub_properties) lbclient.publish(topics[0], b"sub identifier test", 1, retain=False) @@ -940,12 +940,12 @@ def test_subscription_identifiers(self): def test_request_response(self): clientid = 'request response' - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) lacallback.wait_connected() laclient.loop_start() - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.connect(host="localhost", port=self._test_broker_port) lbcallback.wait_connected() lbclient.loop_start() @@ -991,7 +991,7 @@ def test_client_topic_alias(self): clientid = 'client topic alias' # no server side topic aliases allowed - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) connack = lacallback.wait_connected() laclient.loop_start() @@ -1008,7 +1008,7 @@ def test_client_topic_alias(self): connect_properties = Properties(PacketTypes.CONNECT) connect_properties.TopicAliasMaximum = 0 # server topic aliases not allowed connect_properties.SessionExpiryInterval = 99999 - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) connack = lacallback.wait_connected() clientTopicAliasMaximum = 0 @@ -1041,7 +1041,7 @@ def test_client_topic_alias(self): laclient.loop_stop() # check aliases have been deleted - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port, clean_start=False, properties=connect_properties) @@ -1065,7 +1065,7 @@ def test_server_topic_alias(self): connect_properties = Properties(PacketTypes.CONNECT) connect_properties.TopicAliasMaximum = serverTopicAliasMaximum - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) connack = lacallback.wait_connected() laclient.loop_start() @@ -1104,7 +1104,7 @@ def test_server_topic_alias(self): connect_properties = Properties(PacketTypes.CONNECT) # connect_properties.TopicAliasMaximum = serverTopicAliasMaximum # default is 0 - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) connack = lacallback.wait_connected() laclient.loop_start() @@ -1136,7 +1136,7 @@ def test_server_topic_alias(self): connect_properties = Properties(PacketTypes.CONNECT) connect_properties.TopicAliasMaximum = serverTopicAliasMaximum # default is 0 - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) connack = lacallback.wait_connected() laclient.loop_start() @@ -1168,7 +1168,7 @@ def test_maximum_packet_size(self): clientid = 'maximum packet size' # 1. server max packet size - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) connack = lacallback.wait_connected() laclient.loop_start() @@ -1197,7 +1197,7 @@ def test_maximum_packet_size(self): connect_properties = Properties(PacketTypes.CONNECT) connect_properties.MaximumPacketSize = maximumPacketSize - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) connack = lacallback.wait_connected() laclient.loop_start() @@ -1255,7 +1255,7 @@ def test_will_delay(self): will_properties.WillDelayInterval = 3 # in seconds connect_properties.SessionExpiryInterval = 5 - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.will_set( topics[0], payload=b"test_will_delay will message", properties=will_properties) laclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) @@ -1264,7 +1264,7 @@ def test_will_delay(self): self.assertEqual(connack["flags"]["session present"], False) laclient.loop_start() - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.connect(host="localhost", port=self._test_broker_port, properties=connect_properties) connack = lbcallback.wait_connected() lbclient.loop_start() @@ -1291,10 +1291,10 @@ def test_will_delay(self): def test_shared_subscriptions(self): clientid = 'shared subscriptions' - shared_sub_topic = '$share/sharename/' + topic_prefix + 'x' - shared_pub_topic = topic_prefix + 'x' + shared_sub_topic = f"$share/sharename/{topic_prefix}x" + shared_pub_topic = f"{topic_prefix}x" - laclient, lacallback = self.new_client(clientid+" a") + laclient, lacallback = self.new_client(f"{clientid} a") laclient.connect(host="localhost", port=self._test_broker_port) connack = lacallback.wait_connected() laclient.loop_start() @@ -1306,7 +1306,7 @@ def test_shared_subscriptions(self): [(shared_sub_topic, SubscribeOptions(2)), (topics[0], SubscribeOptions(2))]) response = lacallback.wait_subscribed() - lbclient, lbcallback = self.new_client(clientid+" b") + lbclient, lbcallback = self.new_client(f"{clientid} b") lbclient.connect(host="localhost", port=self._test_broker_port) connack = lbcallback.wait_connected() lbclient.loop_start() @@ -1323,7 +1323,7 @@ def test_shared_subscriptions(self): count = 1 for i in range(count): - lbclient.publish(topics[0], "message "+str(i), 0) + lbclient.publish(topics[0], f"message {i}", 0) j = 0 while len(lacallback.messages) + len(lbcallback.messages) < 2*count and j < 20: time.sleep(.1) @@ -1336,7 +1336,7 @@ def test_shared_subscriptions(self): lbcallback.clear() for i in range(count): - lbclient.publish(shared_pub_topic, "message "+str(i), 0) + lbclient.publish(shared_pub_topic, f"message {i}", 0) j = 0 while len(lacallback.messages) + len(lbcallback.messages) < count and j < 20: time.sleep(.1) diff --git a/tests/test_websocket_integration.py b/tests/test_websocket_integration.py index dcbcc21d..80872f9e 100644 --- a/tests/test_websocket_integration.py +++ b/tests/test_websocket_integration.py @@ -81,7 +81,7 @@ def _get_basic_handler(self, response_headers): class WebsocketHandler(socketserver.BaseRequestHandler): def handle(_self): self.data = _self.request.recv(1024).strip() - print("Received '{:s}'".format(self.data.decode("utf8"))) + print('Received', self.data.decode('utf8')) # Respond with data passed in to serve() _self.request.sendall(response) @@ -138,7 +138,7 @@ def _get_callback_handler(self, response_headers, check_request=None): class WebsocketHandler(socketserver.BaseRequestHandler): def handle(_self): self.data = _self.request.recv(1024).strip() - print("Received '{:s}'".format(self.data.decode("utf8"))) + print('Received', self.data.decode('utf8')) decoded = self.data.decode("utf8") @@ -202,7 +202,7 @@ def test_correct_path(self, proto_ver, proto_name, fake_websocket_broker, def check_path_correct(decoded): # Make sure it connects to the right path if mqtt_path: - assert re.search(f"GET {mqtt_path:s} HTTP/1.1", decoded, re.IGNORECASE) is not None + assert re.search(f"GET {mqtt_path} HTTP/1.1", decoded, re.IGNORECASE) is not None response = self._get_callback_handler( init_response_headers, @@ -237,8 +237,8 @@ def test_correct_auth(self, proto_ver, proto_name, fake_websocket_broker, def check_headers_used(decoded): # Make sure it connects to the right path if auth_headers: - for h in auth_headers: - assert re.search(f"{h:s}: {auth_headers[h]:s}", decoded, re.IGNORECASE) is not None + for k, v in auth_headers.items(): + assert f"{k}: {v}" in decoded response = self._get_callback_handler( init_response_headers,