@@ -31,6 +31,7 @@ def test_01_con_discon_success(self, proto_ver, callback_version, fake_broker):
31
31
callback_version ,
32
32
"01-con-discon-success" ,
33
33
protocol = proto_ver ,
34
+ transport = fake_broker .transport ,
34
35
)
35
36
36
37
def on_connect (mqttc , obj , flags , rc_or_reason_code , properties_or_none = None ):
@@ -70,7 +71,8 @@ def on_connect(mqttc, obj, flags, rc_or_reason_code, properties_or_none=None):
70
71
71
72
def test_01_con_failure_rc (self , proto_ver , callback_version , fake_broker ):
72
73
mqttc = client .Client (
73
- callback_version , "01-con-failure-rc" , protocol = proto_ver )
74
+ callback_version , "01-con-failure-rc" ,
75
+ protocol = proto_ver , transport = fake_broker .transport )
74
76
75
77
def on_connect (mqttc , obj , flags , rc_or_reason_code , properties_or_none = None ):
76
78
assert rc_or_reason_code > 0
@@ -107,7 +109,9 @@ def on_connect(mqttc, obj, flags, rc_or_reason_code, properties_or_none=None):
107
109
mqttc .loop_stop ()
108
110
109
111
def test_connection_properties (self , proto_ver , callback_version , fake_broker ):
110
- mqttc = client .Client (CallbackAPIVersion .VERSION2 , "client-id" , protocol = proto_ver )
112
+ mqttc = client .Client (
113
+ CallbackAPIVersion .VERSION2 , "client-id" ,
114
+ protocol = proto_ver , transport = fake_broker .transport )
111
115
mqttc .enable_logger ()
112
116
113
117
is_connected = threading .Event ()
@@ -131,7 +135,7 @@ def on_disconnect(*args):
131
135
mqttc .keepalive = 7
132
136
mqttc .max_inflight_messages = 7
133
137
mqttc .max_queued_messages = 7
134
- mqttc .transport = "tcp"
138
+ mqttc .transport = fake_broker . transport
135
139
mqttc .username = "username"
136
140
mqttc .password = "password"
137
141
@@ -184,7 +188,7 @@ def on_disconnect(*args):
184
188
mqttc .max_queued_messages = 7
185
189
186
190
with pytest .raises (RuntimeError ):
187
- mqttc .transport = "tcp"
191
+ mqttc .transport = fake_broker . transport
188
192
189
193
with pytest .raises (RuntimeError ):
190
194
mqttc .username = "username"
@@ -217,7 +221,9 @@ class Test_connect_v5:
217
221
"""
218
222
219
223
def test_01_broker_no_support (self , fake_broker ):
220
- mqttc = client .Client (CallbackAPIVersion .VERSION2 , "01-broker-no-support" , protocol = MQTTProtocolVersion .MQTTv5 )
224
+ mqttc = client .Client (
225
+ CallbackAPIVersion .VERSION2 , "01-broker-no-support" ,
226
+ protocol = MQTTProtocolVersion .MQTTv5 , transport = fake_broker .transport )
221
227
222
228
def on_connect (mqttc , obj , flags , reason , properties ):
223
229
assert reason == 132
@@ -261,6 +267,7 @@ def test_with_loop_start(self, fake_broker: FakeBroker):
261
267
"test_with_loop_start" ,
262
268
protocol = MQTTProtocolVersion .MQTTv311 ,
263
269
reconnect_on_failure = False ,
270
+ transport = fake_broker .transport
264
271
)
265
272
266
273
on_connect_reached = threading .Event ()
@@ -311,6 +318,7 @@ def test_with_loop(self, fake_broker: FakeBroker):
311
318
CallbackAPIVersion .VERSION1 ,
312
319
"test_with_loop" ,
313
320
clean_session = True ,
321
+ transport = fake_broker .transport ,
314
322
)
315
323
316
324
on_connect_reached = threading .Event ()
@@ -367,6 +375,7 @@ def test_publish_before_connect(self, fake_broker: FakeBroker) -> None:
367
375
mqttc = client .Client (
368
376
CallbackAPIVersion .VERSION1 ,
369
377
"test_publish_before_connect" ,
378
+ transport = fake_broker .transport ,
370
379
)
371
380
372
381
def on_connect (mqttc , obj , flags , rc ):
@@ -424,7 +433,7 @@ def on_connect(mqttc, obj, flags, rc):
424
433
])
425
434
class TestPublishBroker2Client :
426
435
def test_invalid_utf8_topic (self , callback_version , fake_broker ):
427
- mqttc = client .Client (callback_version , "client-id" )
436
+ mqttc = client .Client (callback_version , "client-id" , transport = fake_broker . transport )
428
437
429
438
def on_message (client , userdata , msg ):
430
439
with pytest .raises (UnicodeDecodeError ):
@@ -466,7 +475,7 @@ def on_message(client, userdata, msg):
466
475
assert not packet_in # Check connection is closed
467
476
468
477
def test_valid_utf8_topic_recv (self , callback_version , fake_broker ):
469
- mqttc = client .Client (callback_version , "client-id" )
478
+ mqttc = client .Client (callback_version , "client-id" , transport = fake_broker . transport )
470
479
471
480
# It should be non-ascii multi-bytes character
472
481
topic = unicodedata .lookup ('SNOWMAN' )
@@ -512,7 +521,7 @@ def on_message(client, userdata, msg):
512
521
assert not packet_in # Check connection is closed
513
522
514
523
def test_valid_utf8_topic_publish (self , callback_version , fake_broker ):
515
- mqttc = client .Client (callback_version , "client-id" )
524
+ mqttc = client .Client (callback_version , "client-id" , transport = fake_broker . transport )
516
525
517
526
# It should be non-ascii multi-bytes character
518
527
topic = unicodedata .lookup ('SNOWMAN' )
@@ -558,7 +567,7 @@ def test_valid_utf8_topic_publish(self, callback_version, fake_broker):
558
567
assert not packet_in # Check connection is closed
559
568
560
569
def test_message_callback (self , callback_version , fake_broker ):
561
- mqttc = client .Client (callback_version , "client-id" )
570
+ mqttc = client .Client (callback_version , "client-id" , transport = fake_broker . transport )
562
571
userdata = {
563
572
'on_message' : 0 ,
564
573
'callback1' : 0 ,
@@ -698,6 +707,7 @@ def test_callback_v1_mqtt3(self, fake_broker):
698
707
CallbackAPIVersion .VERSION1 ,
699
708
"client-id" ,
700
709
userdata = callback_called ,
710
+ transport = fake_broker .transport ,
701
711
)
702
712
703
713
def on_connect (cl , userdata , flags , rc ):
@@ -823,6 +833,7 @@ def test_callback_v2_mqtt3(self, fake_broker):
823
833
CallbackAPIVersion .VERSION2 ,
824
834
"client-id" ,
825
835
userdata = callback_called ,
836
+ transport = fake_broker .transport ,
826
837
)
827
838
828
839
def on_connect (cl , userdata , flags , reason , properties ):
0 commit comments