From 6139782d8116054cba0857db862c66c6cb0b4094 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 12 Oct 2021 17:57:40 +1100 Subject: [PATCH] Tests: script_pyapi_idprop now cleans up after it's self This test left blend files in the users temporary directory. --- tests/python/bl_pyapi_idprop_datablock.py | 26 ++++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/python/bl_pyapi_idprop_datablock.py b/tests/python/bl_pyapi_idprop_datablock.py index 63070dc2cb3..6cc99154cfe 100644 --- a/tests/python/bl_pyapi_idprop_datablock.py +++ b/tests/python/bl_pyapi_idprop_datablock.py @@ -16,6 +16,8 @@ # # ##### END GPL LICENSE BLOCK ##### +# ./blender.bin --background -noaudio --python tests/python/bl_pyapi_idprop_datablock.py -- --verbose + import bpy import sys import os @@ -25,8 +27,10 @@ from bpy.types import UIList arr_len = 100 ob_cp_count = 100 -lib_path = os.path.join(tempfile.gettempdir(), "lib.blend") -test_path = os.path.join(tempfile.gettempdir(), "test.blend") + +# Set before execution. +lib_path = None +test_path = None def print_fail_msg_and_exit(msg): @@ -321,12 +325,18 @@ def test_restrictions2(): def main(): - init() - test_users_counting() - test_linking() - test_restrictions1() - check_crash(test_regressions) - test_restrictions2() + global lib_path + global test_path + with tempfile.TemporaryDirectory() as temp_dir: + lib_path = os.path.join(temp_dir, "lib.blend") + test_path = os.path.join(temp_dir, "test.blend") + + init() + test_users_counting() + test_linking() + test_restrictions1() + check_crash(test_regressions) + test_restrictions2() if __name__ == "__main__":