@@ -548,45 +548,6 @@ class SimulatedError(Exception):
548548 assert close_called is True , "Exception inside context manager bypassed cleanup!"
549549
550550
551- def test_client_unclosed_resource_warning () -> None :
552- """Verify CWE-772 mitigation: GC on an unclosed client emits a ResourceWarning."""
553- orphan_client = Client (auth = ("test" , "test" ))
554-
555- with pytest .warns (ResourceWarning , match = "Unclosed Mailjet Client" ):
556- del orphan_client
557- gc .collect ()
558-
559- def test_client_context_manager_clean_exit () -> None :
560- """Verify that using the context manager safely closes the session without warnings."""
561- with warnings .catch_warnings ():
562- warnings .simplefilter ("error" , ResourceWarning )
563- with Client (auth = ("test" , "test" )) as safe_client :
564- pass # Do nothing
565-
566- del safe_client
567- gc .collect ()
568-
569-
570- def test_client_leakage_triggers_resource_warning () -> None :
571- """Verify that an unclosed client triggers a ResourceWarning."""
572- client = Client (auth = ("test" , "test" ))
573-
574- with pytest .warns (ResourceWarning , match = "Please use the context manager" ):
575- del client
576- gc .collect ()
577-
578-
579- def test_client_cleanup_no_warning () -> None :
580- """Verify that an explicitly closed client does NOT trigger a warning."""
581- with warnings .catch_warnings ():
582- warnings .simplefilter ("error" , ResourceWarning )
583- client = Client (auth = ("test" , "test" ))
584- client .close ()
585-
586- del client
587- gc .collect ()
588-
589-
590551# ==========================================
591552# 6. Performance & Memory Optimization Tests
592553# ==========================================
0 commit comments