def tearDown(self):
        """Check for running tasks and non-main threads after each test.

        Raises:
            AssertionError: If there are any running tasks running and the
                environment variable `TEST_TASKS_CLEANUP` is set.

            AssertionError: If there are any non-main threads running and the
                environment variable `TEST_THREADS_CLEANUP` is set.
        """
        self.clear_TruSession_singleton()

        # GC here to make sure we don't have any references to tasks or threads
        # that are keeping them alive.
        gc.collect()

        running_tasks = []
        try:
            loop = asyncio.get_event_loop()
            for task in asyncio.all_tasks(loop):
                running_tasks.append(task)
        except Exception:
            # No event loop running?
            pass

        if running_tasks:
            if self.env_true(TEST_TASKS_CLEANUP_VAR):
                with self.subTest(part="running tasks"):
                    raise AssertionError(
                        f"Tasks still running: {running_tasks}"
                    )
            else:
                print(f"Tasks still running: {running_tasks}")

        non_main_threads = [
            thread
            for thread in threading.enumerate()
            if thread != threading.main_thread()
        ]

        if non_main_threads:
            if self.env_true(TEST_THREADS_CLEANUP_VAR):
                with self.subTest(part="non-main threads"):
                    raise AssertionError(
                        f"Non-main threads still running: {non_main_threads}"
                    )
            else:
                print(f"Non-main threads still running: {non_main_threads}")

        super().tearDown()
Check for running tasks and non-main threads after each test.

        Raises:
            AssertionError: If there are any running tasks running and the
                environment variable `TEST_TASKS_CLEANUP` is set.

            AssertionError: If there are any non-main threads running and the
                environment variable `TEST_THREADS_CLEANUP` is set.
        
tests/test.py