8
8
import random
9
9
import re
10
10
import string
11
- import sys
12
11
import time
13
12
from collections import namedtuple
14
13
from threading import Thread
@@ -418,7 +417,6 @@ def handler(event, context):
418
417
assert "stack_trace" not in log
419
418
420
419
421
- @pytest .mark .skipif (reason = "Test temporarily disabled" )
422
420
def test_thread_safe_keys_encapsulation (service_name , stdout ):
423
421
logger = Logger (
424
422
service = service_name ,
@@ -434,9 +432,16 @@ def send_thread_message_with_key(message, keys):
434
432
logger .info ("global key added" )
435
433
436
434
thread1_keys = {"exampleThread1Key" : "thread1" }
437
- Thread (target = send_thread_message_with_key , args = ("thread1" , thread1_keys )).start ()
435
+ thread1 = Thread (target = send_thread_message_with_key , args = ("thread1" , thread1_keys ))
436
+
437
+ thread1 .start ()
438
+ thread1 .join ()
439
+
438
440
thread2_keys = {"exampleThread2Key" : "thread2" }
439
- Thread (target = send_thread_message_with_key , args = ("thread2" , thread2_keys )).start ()
441
+ thread2 = Thread (target = send_thread_message_with_key , args = ("thread2" , thread2_keys ))
442
+
443
+ thread2 .start ()
444
+ thread2 .join ()
440
445
441
446
logger .info ("final log, all thread keys gone" )
442
447
@@ -457,7 +462,6 @@ def send_thread_message_with_key(message, keys):
457
462
assert logs [3 ].get ("exampleThread2Key" ) is None
458
463
459
464
460
- @pytest .mark .skipif (sys .version_info >= (3 , 13 ), reason = "Test temporarily disabled for Python 3.13+" )
461
465
def test_thread_safe_remove_key (service_name , stdout ):
462
466
logger = Logger (
463
467
service = service_name ,
@@ -471,10 +475,12 @@ def send_message_with_key_and_without(message, keys):
471
475
logger .info (message )
472
476
473
477
thread1_keys = {"exampleThread1Key" : "thread1" }
474
- Thread (target = send_message_with_key_and_without , args = ("msg" , thread1_keys )).start ()
478
+ thread1 = Thread (target = send_message_with_key_and_without , args = ("msg" , thread1_keys ))
479
+
480
+ thread1 .start ()
481
+ thread1 .join ()
475
482
476
483
logs = capture_logging_output (stdout )
477
- print (logs )
478
484
479
485
assert logs [0 ].get ("exampleThread1Key" ) == "thread1"
480
486
assert logs [1 ].get ("exampleThread1Key" ) is None
@@ -493,10 +499,12 @@ def send_message_with_key_and_clear(message, keys):
493
499
logger .info (message )
494
500
495
501
thread1_keys = {"exampleThread1Key" : "thread1" }
496
- Thread (target = send_message_with_key_and_clear , args = ("msg" , thread1_keys )).start ()
502
+ thread1 = Thread (target = send_message_with_key_and_clear , args = ("msg" , thread1_keys ))
503
+
504
+ thread1 .start ()
505
+ thread1 .join ()
497
506
498
507
logs = capture_logging_output (stdout )
499
- print (logs )
500
508
501
509
assert logs [0 ].get ("exampleThread1Key" ) == "thread1"
502
510
assert logs [1 ].get ("exampleThread1Key" ) is None
@@ -513,10 +521,12 @@ def send_message_with_key_and_get(message, keys):
513
521
logger .info (logger .thread_safe_get_current_keys ())
514
522
515
523
thread1_keys = {"exampleThread1Key" : "thread1" }
516
- Thread (target = send_message_with_key_and_get , args = ("msg" , thread1_keys )).start ()
524
+ thread1 = Thread (target = send_message_with_key_and_get , args = ("msg" , thread1_keys ))
525
+
526
+ thread1 .start ()
527
+ thread1 .join ()
517
528
518
529
logs = capture_logging_output (stdout )
519
- print (logs )
520
530
521
531
assert logs [0 ].get ("exampleThread1Key" ) == "thread1"
522
532
assert logs [0 ].get ("message" ) == thread1_keys
0 commit comments