'A context manager to use around all finalization tests.'

@classmethod
@contextlib.contextmanager
def test(cls):

    with support.disable_gc():
        cls.del_calls.clear()
        cls.tp_del_calls.clear()
        NonGCSimpleBase._cleaning = False
        try:
            (yield)
            if cls.errors:
                raise cls.errors[0]
        finally:
            NonGCSimpleBase._cleaning = True
            cls._cleanup()
