Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/python/bl_load_addons.py')
-rw-r--r--tests/python/bl_load_addons.py34
1 files changed, 24 insertions, 10 deletions
diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py
index f04ae64ee73..227edf4164d 100644
--- a/tests/python/bl_load_addons.py
+++ b/tests/python/bl_load_addons.py
@@ -20,12 +20,28 @@
# simple script to enable all addons, and disable
+"""
+./blender.bin --background -noaudio --factory-startup --python tests/python/bl_load_addons.py
+"""
+
import bpy
import addon_utils
+import os
import sys
import imp
+BLACKLIST_DIRS = (
+ os.path.join(bpy.utils.resource_path('USER'), "scripts"),
+ ) + tuple(addon_utils.paths()[1:])
+
+
+def addon_modules_sorted():
+ modules = addon_utils.modules({})
+ modules[:] = [mod for mod in modules if not mod.__file__.startswith(BLACKLIST_DIRS)]
+ modules.sort(key=lambda mod: mod.__name__)
+ return modules
+
def disable_addons():
# first disable all
@@ -36,8 +52,7 @@ def disable_addons():
def test_load_addons():
- modules = addon_utils.modules({})
- modules.sort(key=lambda mod: mod.__name__)
+ modules = addon_modules_sorted()
disable_addons()
@@ -48,7 +63,7 @@ def test_load_addons():
for mod in modules:
mod_name = mod.__name__
print("\tenabling:", mod_name)
- addon_utils.enable(mod_name)
+ addon_utils.enable(mod_name, default_set=True)
if mod_name not in addons:
addons_fail.append(mod_name)
@@ -62,8 +77,7 @@ def test_load_addons():
def reload_addons(do_reload=True, do_reverse=True):
- modules = addon_utils.modules({})
- modules.sort(key=lambda mod: mod.__name__)
+ modules = addon_modules_sorted()
addons = bpy.context.user_preferences.addons
disable_addons()
@@ -73,10 +87,10 @@ def reload_addons(do_reload=True, do_reverse=True):
for mod in modules:
mod_name = mod.__name__
print("\tenabling:", mod_name)
- addon_utils.enable(mod_name)
+ addon_utils.enable(mod_name, default_set=True)
assert(mod_name in addons)
- for mod in addon_utils.modules({}):
+ for mod in modules:
mod_name = mod.__name__
print("\tdisabling:", mod_name)
addon_utils.disable(mod_name)
@@ -86,9 +100,9 @@ def reload_addons(do_reload=True, do_reverse=True):
if do_reload:
imp.reload(sys.modules[mod_name])
- if do_reverse:
- # in case order matters when it shouldn't
- modules.reverse()
+ if do_reverse:
+ # in case order matters when it shouldn't
+ modules.reverse()
def main():