66import gc
77import weakref
88import logging
9+ import contextlib
910import unittest
1011
1112from vsengine ._hospice import admit_environment , any_alive , freeze , unfreeze
1415class Obj : pass
1516
1617
18+ @contextlib .contextmanager
19+ def hide_logs ():
20+ logging .disable (logging .CRITICAL )
21+ try :
22+ yield
23+ finally :
24+ logging .disable (logging .NOTSET )
25+
1726class HospiceTest (unittest .TestCase ):
1827
1928 def test_hospice_delays_connection (self ):
@@ -62,7 +71,8 @@ def test_hospice_reports_alive_objects_correctly(self):
6271 admit_environment (o1 , o2 )
6372 del o1
6473
65- self .assertTrue (any_alive (), "The hospice did report that all objects are not alive anymore. This is obviously not true." )
74+ with hide_logs ():
75+ self .assertTrue (any_alive (), "The hospice did report that all objects are not alive anymore. This is obviously not true." )
6676 del o2
6777
6878 self .assertFalse (any_alive (), "The hospice did report that there are some objects left alive. This is obviously not true." )
@@ -73,12 +83,14 @@ def test_hospice_can_forget_about_cores_safely(self):
7383 admit_environment (o1 , o2 )
7484 del o1
7585
76- self .assertTrue (any_alive (), "The hospice did report that all objects are not alive anymore. This is obviously not true." )
86+ with hide_logs ():
87+ self .assertTrue (any_alive (), "The hospice did report that all objects are not alive anymore. This is obviously not true." )
7788 freeze ()
7889 self .assertFalse (any_alive (), "The hospice did report that there are some objects left alive. This is obviously not true." )
7990
8091 unfreeze ()
81- self .assertTrue (any_alive (), "The hospice did report that all objects are not alive anymore. This is obviously not true." )
92+ with hide_logs ():
93+ self .assertTrue (any_alive (), "The hospice did report that all objects are not alive anymore. This is obviously not true." )
8294 del o2
8395
8496 gc .collect ()
0 commit comments