diff --git a/tests/bin/start b/tests/bin/start index b3d73dd..fbdc895 100755 --- a/tests/bin/start +++ b/tests/bin/start @@ -5,7 +5,6 @@ set -e cd "$(dirname "${BASH_SOURCE[0]}")/../.." export PYTHONPATH=.ten/app/ten_packages/system/ten_runtime_python/lib:.ten/app/ten_packages/system/ten_runtime_python/interface -export TEN_DISABLE_ADDON_UNREGISTER_AFTER_APP_CLOSE=true # If the Python app imports some modules that are compiled with a different # version of libstdc++ (ex: PyTorch), the Python app may encounter confusing diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..27f004f --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,36 @@ +# +# Copyright © 2025 Agora +# This file is part of TEN Framework, an open source project. +# Licensed under the Apache License, Version 2.0, with certain conditions. +# Refer to the "LICENSE" file in the root directory for more information. +# +import pytest +import sys +import os +from ten import ( + unregister_all_addons_and_cleanup, +) + + +@pytest.fixture(scope="session", autouse=True) +def global_setup_and_teardown(): + # Set the environment variable. + os.environ["TEN_DISABLE_ADDON_UNREGISTER_AFTER_APP_CLOSE"] = "true" + + # Verify the environment variable is correctly set. + if ( + "TEN_DISABLE_ADDON_UNREGISTER_AFTER_APP_CLOSE" not in os.environ + or os.environ["TEN_DISABLE_ADDON_UNREGISTER_AFTER_APP_CLOSE"] != "true" + ): + print( + "Failed to set TEN_DISABLE_ADDON_UNREGISTER_AFTER_APP_CLOSE", + file=sys.stderr, + ) + sys.exit(1) + + # Yield control to the test; after the test execution is complete, continue + # with the teardown process. + yield + + # Teardown part. + unregister_all_addons_and_cleanup()