Skip to content

Commit 841cf47

Browse files
committed
tests: Hide core-in use message at specfic points as they are expected
1 parent 80a7e4d commit 841cf47

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tests/test_hospice.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import gc
77
import weakref
88
import logging
9+
import contextlib
910
import unittest
1011

1112
from vsengine._hospice import admit_environment, any_alive, freeze, unfreeze
@@ -14,6 +15,14 @@
1415
class 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+
1726
class 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

Comments
 (0)