1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 # simple script to enable all addons, and disable
31 addons = bpy.context.user_preferences.addons
32 for mod_name in list(addons.keys()):
33 addon_utils.disable(mod_name)
34 assert(bool(addons) is False)
37 def test_load_addons():
38 modules = addon_utils.modules({})
39 modules.sort(key=lambda mod: mod.__name__)
43 addons = bpy.context.user_preferences.addons
48 mod_name = mod.__name__
49 print("\tenabling:", mod_name)
50 addon_utils.enable(mod_name)
51 if mod_name not in addons:
52 addons_fail.append(mod_name)
55 print("addons failed to load (%d):" % len(addons_fail))
56 for mod_name in addons_fail:
57 print(" %s" % mod_name)
59 print("addons all loaded without errors!")
63 def reload_addons(do_reload=True, do_reverse=True):
64 modules = addon_utils.modules({})
65 modules.sort(key=lambda mod: mod.__name__)
66 addons = bpy.context.user_preferences.addons
70 # Run twice each time.
73 mod_name = mod.__name__
74 print("\tenabling:", mod_name)
75 addon_utils.enable(mod_name)
76 assert(mod_name in addons)
78 for mod in addon_utils.modules({}):
79 mod_name = mod.__name__
80 print("\tdisabling:", mod_name)
81 addon_utils.disable(mod_name)
82 assert(not (mod_name in addons))
86 imp.reload(sys.modules[mod_name])
89 # in case order matters when it shouldnt
94 # first load addons, print a list of all addons that fail
97 reload_addons(do_reload=False, do_reverse=False)
98 reload_addons(do_reload=False, do_reverse=True)
99 reload_addons(do_reload=True, do_reverse=True)
102 if __name__ == "__main__":
104 # So a python error exits(1)
109 traceback.print_exc()