From 39c341bf4ab9582edc26227447634cae2004baa6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 14 Sep 2022 16:18:59 +1000 Subject: Cleanup: remove redundant braces from assert & raise autopep8 v1.7 added a space after assert & raise, remove the braces as they aren't needed. --- doc/manpage/blender.1.py | 2 +- doc/python_api/rst_from_bmesh_opdefines.py | 22 +- doc/python_api/sphinx_changelog_gen.py | 16 +- doc/python_api/sphinx_doc_gen.py | 2 +- release/datafiles/blender_icons_geom.py | 8 +- release/datafiles/ctodata.py | 2 +- .../freestyle/modules/freestyle/functions.py | 2 +- .../scripts/modules/bl_app_override/__init__.py | 8 +- release/scripts/modules/bl_app_override/helpers.py | 4 +- .../autocomplete/complete_import.py | 4 +- .../autocomplete/complete_namespace.py | 4 +- release/scripts/modules/bl_i18n_utils/settings.py | 2 +- release/scripts/modules/bl_i18n_utils/utils.py | 2 +- release/scripts/modules/bl_keymap_utils/io.py | 2 +- release/scripts/modules/bpy_extras/io_utils.py | 2 +- .../modules/bpy_extras/node_shader_utils.py | 2 +- .../modules/bpy_extras/wm_utils/progress_report.py | 4 +- release/scripts/modules/rna_prop_ui.py | 4 +- .../keyconfig/keymap_data/blender_default.py | 2 +- .../startup/bl_operators/uvcalc_follow_active.py | 2 +- .../startup/bl_operators/uvcalc_lightmap.py | 2 +- release/scripts/startup/bl_operators/wm.py | 10 +- .../startup/bl_ui/space_toolsystem_common.py | 2 +- .../scripts/startup/bl_ui/space_view3d_toolbar.py | 6 +- source/blender/datatoc/datatoc_icon.py | 4 +- tests/python/bl_blendfile_io.py | 4 +- tests/python/bl_blendfile_liblink.py | 264 ++++++++++----------- tests/python/bl_blendfile_library_overrides.py | 140 +++++------ tests/python/bl_keymap_validate.py | 2 +- tests/python/bl_load_addons.py | 6 +- tests/python/bl_load_py_modules.py | 2 +- tests/python/bl_mesh_modifiers.py | 6 +- tests/python/bl_pyapi_idprop.py | 2 +- tests/python/bl_rna_manual_reference.py | 8 +- tests/python/bl_run_operators_event_simulate.py | 2 +- 35 files changed, 280 insertions(+), 276 deletions(-) diff --git a/doc/manpage/blender.1.py b/doc/manpage/blender.1.py index 7d35dc0abb1..49dae35e0c5 100755 --- a/doc/manpage/blender.1.py +++ b/doc/manpage/blender.1.py @@ -139,7 +139,7 @@ https://www.blender.org''') l = lines.pop(0) if l: - assert(l.startswith('\t')) + assert l.startswith('\t') l = l[1:] # Remove first white-space (tab). fh.write('%s\n' % man_format(l)) diff --git a/doc/python_api/rst_from_bmesh_opdefines.py b/doc/python_api/rst_from_bmesh_opdefines.py index 3d8ff1e6248..0614538964d 100644 --- a/doc/python_api/rst_from_bmesh_opdefines.py +++ b/doc/python_api/rst_from_bmesh_opdefines.py @@ -241,9 +241,9 @@ def main(): comment_washed = [] comment = [] if comment is None else comment for i, l in enumerate(comment): - assert((l.strip() == "") or - (l in {"/*", " *"}) or - (l.startswith(("/* ", " * ")))) + assert ((l.strip() == "") or + (l in {"/*", " *"}) or + (l.startswith(("/* ", " * ")))) l = l[3:] if i == 0 and not l.strip(): @@ -270,7 +270,7 @@ def main(): tp_sub = None else: print(arg) - assert(0) + assert 0 tp_str = "" @@ -315,7 +315,7 @@ def main(): tp_str += " or any sequence of 3 floats" elif tp == BMO_OP_SLOT_PTR: tp_str = "dict" - assert(tp_sub is not None) + assert tp_sub is not None if tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_BMESH: tp_str = ":class:`bmesh.types.BMesh`" elif tp_sub == BMO_OP_SLOT_SUBTYPE_PTR_SCENE: @@ -330,10 +330,10 @@ def main(): tp_str = ":class:`bpy.types.bpy_struct`" else: print("Can't find", vars_dict_reverse[tp_sub]) - assert(0) + assert 0 elif tp == BMO_OP_SLOT_ELEMENT_BUF: - assert(tp_sub is not None) + assert tp_sub is not None ls = [] if tp_sub & BM_VERT: @@ -342,7 +342,7 @@ def main(): ls.append(":class:`bmesh.types.BMEdge`") if tp_sub & BM_FACE: ls.append(":class:`bmesh.types.BMFace`") - assert(ls) # must be at least one + assert ls # Must be at least one. if tp_sub & BMO_OP_SLOT_SUBTYPE_ELEM_IS_SINGLE: tp_str = "/".join(ls) @@ -367,10 +367,10 @@ def main(): tp_str += "unknown internal data, not compatible with python" else: print("Can't find", vars_dict_reverse[tp_sub]) - assert(0) + assert 0 else: print("Can't find", vars_dict_reverse[tp]) - assert(0) + assert 0 args_wash.append((name, tp_str, comment)) return args_wash @@ -394,7 +394,7 @@ def main(): fw(" :return:\n\n") for (name, tp, comment) in args_out_wash: - assert(name.endswith(".out")) + assert name.endswith(".out") name = name[:-4] fw(" - ``%s``: %s\n\n" % (name, comment)) fw(" **type** %s\n" % tp) diff --git a/doc/python_api/sphinx_changelog_gen.py b/doc/python_api/sphinx_changelog_gen.py index 4c9f7232a74..e2bbf7c3acd 100644 --- a/doc/python_api/sphinx_changelog_gen.py +++ b/doc/python_api/sphinx_changelog_gen.py @@ -101,7 +101,7 @@ def api_dump(args): version, version_key = api_version() if version is None: - raise(ValueError("API dumps can only be generated from within Blender.")) + raise ValueError("API dumps can only be generated from within Blender.") dump = {} dump_module = dump["bpy.types"] = {} @@ -250,7 +250,7 @@ def api_changelog(args): version, version_key = api_version() if version is None and (filepath_in_from is None or filepath_in_to is None): - raise(ValueError("API dumps files must be given when ran outside of Blender.")) + raise ValueError("API dumps files must be given when ran outside of Blender.") with open(indexpath, 'r', encoding='utf-8') as file_handle: index = json.load(file_handle) @@ -258,17 +258,21 @@ def api_changelog(args): if filepath_in_to is None: filepath_in_to = index.get(version_key, None) if filepath_in_to is None: - raise(ValueError("Cannot find API dump file for Blender version " + str(version) + " in index file.")) + raise ValueError("Cannot find API dump file for Blender version " + str(version) + " in index file.") print("Found to file: %r" % filepath_in_to) if filepath_in_from is None: version_from, version_from_key = api_version_previous_in_index(index, version) if version_from is None: - raise(ValueError("No previous version of Blender could be found in the index.")) + raise ValueError("No previous version of Blender could be found in the index.") filepath_in_from = index.get(version_from_key, None) if filepath_in_from is None: - raise(ValueError("Cannot find API dump file for previous Blender version " + str(version_from) + " in index file.")) + raise ValueError( + "Cannot find API dump file for previous Blender version " + + str(version_from) + + " in index file." + ) print("Found from file: %r" % filepath_in_from) @@ -277,7 +281,7 @@ def api_changelog(args): with open(os.path.join(rootpath, filepath_in_to), 'r', encoding='utf-8') as file_handle: dump_version, dict_to = json.load(file_handle) - assert(tuple(dump_version) == version) + assert tuple(dump_version) == version api_changes = [] diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index e07afe44545..0887e9e74d8 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -1477,7 +1477,7 @@ def pyrna2sphinx(basepath): struct_module_name = struct.module_name if USE_ONLY_BUILTIN_RNA_TYPES: - assert (struct_module_name == "bpy.types") + assert struct_module_name == "bpy.types" filepath = os.path.join(basepath, "%s.%s.rst" % (struct_module_name, struct.identifier)) file = open(filepath, "w", encoding="utf-8") fw = file.write diff --git a/release/datafiles/blender_icons_geom.py b/release/datafiles/blender_icons_geom.py index b95baf3419e..878cc4b46f6 100644 --- a/release/datafiles/blender_icons_geom.py +++ b/release/datafiles/blender_icons_geom.py @@ -72,7 +72,7 @@ class TriMesh: @staticmethod def _tri_copy_from_object(ob): import bmesh - assert(ob.type in OBJECTS_TYPES_MESH_COMPATIBLE) + assert ob.type in OBJECTS_TYPES_MESH_COMPATIBLE bm = bmesh.new() bm.from_mesh(ob.to_mesh()) bmesh.ops.triangulate(bm, faces=bm.faces) @@ -143,7 +143,7 @@ def mesh_data_lists_from_mesh(me, material_colors): i1 = 1 # we only write tris now - assert(len(loops_poly) == 3) + assert len(loops_poly) == 3 for i2 in range(2, l_len): l0 = loops_poly[i0] @@ -217,7 +217,7 @@ def mesh_data_lists_from_objects(ob_parent, ob_children): def write_mesh_to_py(fh, ob, ob_children): def float_as_byte(f, axis_range): - assert(axis_range <= 255) + assert axis_range <= 255 # -1..1 -> 0..255 f = (f + 1.0) * 0.5 f = round(f * axis_range) @@ -238,7 +238,7 @@ def write_mesh_to_py(fh, ob, ob_children): if 0: # make as large as we can, keeping alignment def size_scale_up(size): - assert(size != 0) + assert size != 0 while size * 2 <= 255: size *= 2 return size diff --git a/release/datafiles/ctodata.py b/release/datafiles/ctodata.py index b6420d5c9a2..6c5afdb1b5b 100755 --- a/release/datafiles/ctodata.py +++ b/release/datafiles/ctodata.py @@ -31,7 +31,7 @@ data = [int(v) for v in data] if strip_byte: # String data gets trailing byte. last = data.pop() - assert(last == 0) + assert last == 0 data = bytes(data) diff --git a/release/scripts/freestyle/modules/freestyle/functions.py b/release/scripts/freestyle/modules/freestyle/functions.py index 4a4a2f036e1..326e072d34a 100644 --- a/release/scripts/freestyle/modules/freestyle/functions.py +++ b/release/scripts/freestyle/modules/freestyle/functions.py @@ -198,7 +198,7 @@ class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble): class pyCurvilinearLengthF0D(UnaryFunction0DDouble): def __call__(self, inter): cp = inter.object - assert(isinstance(cp, CurvePoint)) + assert isinstance(cp, CurvePoint) return cp.t2d diff --git a/release/scripts/modules/bl_app_override/__init__.py b/release/scripts/modules/bl_app_override/__init__.py index 4d6194e71cd..1408cf3594f 100644 --- a/release/scripts/modules/bl_app_override/__init__.py +++ b/release/scripts/modules/bl_app_override/__init__.py @@ -74,7 +74,7 @@ def ui_draw_filter_register( if ui_test is None: UILayout.__getattribute__(self, "label")(text="") else: - assert(ui_test is True) + assert ui_test is True # may need to be set ret = OperatorProperties_Fake() return ret @@ -95,7 +95,7 @@ def ui_draw_filter_register( if ui_test is None: UILayout.__getattribute__(self, "label")(text="") else: - assert(ui_test is True) + assert ui_test is True ret = None return ret return dummy_func @@ -115,7 +115,7 @@ def ui_draw_filter_register( if ui_test is None: UILayout.__getattribute__(self, "label")(text="") else: - assert(ui_test is True) + assert ui_test is True ret = None return ret return dummy_func @@ -135,7 +135,7 @@ def ui_draw_filter_register( if ui_test is None: real_func(text="") else: - assert(ui_test is True) + assert ui_test is True ret = None return ret return dummy_func diff --git a/release/scripts/modules/bl_app_override/helpers.py b/release/scripts/modules/bl_app_override/helpers.py index 4759e0ae8e5..0b785511886 100644 --- a/release/scripts/modules/bl_app_override/helpers.py +++ b/release/scripts/modules/bl_app_override/helpers.py @@ -44,14 +44,14 @@ class AppOverrideState: self._ui_ignore_store = None def _setup_classes(self): - assert(self._class_store is None) + assert self._class_store is None self._class_store = self.class_ignore() from bpy.utils import unregister_class for cls in self._class_store: unregister_class(cls) def _teardown_classes(self): - assert(self._class_store is not None) + assert self._class_store is not None from bpy.utils import register_class for cls in self._class_store: diff --git a/release/scripts/modules/bl_console_utils/autocomplete/complete_import.py b/release/scripts/modules/bl_console_utils/autocomplete/complete_import.py index 2f321fee0b2..1a97e408b70 100644 --- a/release/scripts/modules/bl_console_utils/autocomplete/complete_import.py +++ b/release/scripts/modules/bl_console_utils/autocomplete/complete_import.py @@ -42,7 +42,7 @@ def get_root_modules(): """ global ROOT_MODULES modules = [] - if not(ROOT_MODULES is None): + if not (ROOT_MODULES is None): return ROOT_MODULES from time import time t = time() @@ -131,7 +131,7 @@ def complete(line): if only_modules: return inspect.ismodule(getattr(module, attr)) else: - return not(attr[:2] == '__' and attr[-2:] == '__') + return not (attr[:2] == '__' and attr[-2:] == '__') try: m = __import__(mod) diff --git a/release/scripts/modules/bl_console_utils/autocomplete/complete_namespace.py b/release/scripts/modules/bl_console_utils/autocomplete/complete_namespace.py index 4ba446d6832..096e5596fc6 100644 --- a/release/scripts/modules/bl_console_utils/autocomplete/complete_namespace.py +++ b/release/scripts/modules/bl_console_utils/autocomplete/complete_namespace.py @@ -132,7 +132,7 @@ def complete(word, namespace, *, private=True): matches = complete_indices(word, namespace, base=re_incomplete_index.group(1)) - elif not('[' in word): + elif not ('[' in word): matches = complete_names(word, namespace) elif word[-1] == ']': @@ -182,7 +182,7 @@ def complete(word, namespace, *, private=True): matches = [word + '.'] # separate public from private - public_matches = [match for match in matches if not('._' in match)] + public_matches = [match for match in matches if not ('._' in match)] if private: private_matches = [match for match in matches if '._' in match] return public_matches + private_matches diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index 77ab70f8d91..374b90446f3 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -87,7 +87,7 @@ LANGUAGES = ( # Default context, in py (keep in sync with `BLT_translation.h`)! if bpy is not None: - assert(bpy.app.translations.contexts.default == "*") + assert bpy.app.translations.contexts.default == "*" DEFAULT_CONTEXT = "*" # Name of language file used by Blender to generate translations' menu. diff --git a/release/scripts/modules/bl_i18n_utils/utils.py b/release/scripts/modules/bl_i18n_utils/utils.py index 324c3ea261d..784b206fb84 100644 --- a/release/scripts/modules/bl_i18n_utils/utils.py +++ b/release/scripts/modules/bl_i18n_utils/utils.py @@ -68,7 +68,7 @@ def locale_explode(locale): try: import bpy.app.translations as bpy_translations - assert(ret == bpy_translations.locale_explode(locale)) + assert ret == bpy_translations.locale_explode(locale) except ModuleNotFoundError: pass diff --git a/release/scripts/modules/bl_keymap_utils/io.py b/release/scripts/modules/bl_keymap_utils/io.py index 5d74ffbcf56..8d849498bd7 100644 --- a/release/scripts/modules/bl_keymap_utils/io.py +++ b/release/scripts/modules/bl_keymap_utils/io.py @@ -229,7 +229,7 @@ def keyconfig_export_as_data(wm, kc, filepath, *, all_keymaps=False): # Take care making changes that could impact performance. def _init_properties_from_data(base_props, base_value): - assert(type(base_value) is list) + assert type(base_value) is list for attr, value in base_value: if type(value) is list: base_props.property_unset(attr) diff --git a/release/scripts/modules/bpy_extras/io_utils.py b/release/scripts/modules/bpy_extras/io_utils.py index 35b7d564a5e..b6da6c7768c 100644 --- a/release/scripts/modules/bpy_extras/io_utils.py +++ b/release/scripts/modules/bpy_extras/io_utils.py @@ -295,7 +295,7 @@ def axis_conversion(from_forward='Y', from_up='Z', to_forward='Y', to_up='Z'): for i, axis_lut in enumerate(_axis_convert_lut): if value in axis_lut: return Matrix(_axis_convert_matrix[i]) - assert(0) + assert 0 def axis_conversion_ensure(operator, forward_attr, up_attr): diff --git a/release/scripts/modules/bpy_extras/node_shader_utils.py b/release/scripts/modules/bpy_extras/node_shader_utils.py index cda291c6c90..0c349084220 100644 --- a/release/scripts/modules/bpy_extras/node_shader_utils.py +++ b/release/scripts/modules/bpy_extras/node_shader_utils.py @@ -13,7 +13,7 @@ def _set_check(func): @wraps(func) def wrapper(self, *args, **kwargs): if self.is_readonly: - assert(not "Trying to set value to read-only shader!") + assert not "Trying to set value to read-only shader!" return return func(self, *args, **kwargs) return wrapper diff --git a/release/scripts/modules/bpy_extras/wm_utils/progress_report.py b/release/scripts/modules/bpy_extras/wm_utils/progress_report.py index 637d60838db..371d598042c 100644 --- a/release/scripts/modules/bpy_extras/wm_utils/progress_report.py +++ b/release/scripts/modules/bpy_extras/wm_utils/progress_report.py @@ -93,7 +93,7 @@ class ProgressReport: def leave_substeps(self, msg=""): if (msg): self.update(msg) - assert(len(self.steps) > 1) + assert len(self.steps) > 1 del self.steps[-1] del self.curr_step[-1] del self.start_time[-1] @@ -134,7 +134,7 @@ class ProgressReportSubstep: return self def __exit__(self, exc_type, exc_value, traceback): - assert(len(self.progress.steps) > self.level) + assert len(self.progress.steps) > self.level while len(self.progress.steps) > self.level + 1: self.progress.leave_substeps() self.progress.leave_substeps(self.final_msg) diff --git a/release/scripts/modules/rna_prop_ui.py b/release/scripts/modules/rna_prop_ui.py index 8b8cfaaccc5..5f4a6b8cf38 100644 --- a/release/scripts/modules/rna_prop_ui.py +++ b/release/scripts/modules/rna_prop_ui.py @@ -127,7 +127,7 @@ def draw(layout, context, context_member, property_type, *, use_edit=True): use_edit = False is_lib_override = rna_item.id_data.override_library and rna_item.id_data.override_library.reference - assert(isinstance(rna_item, property_type)) + assert isinstance(rna_item, property_type) items = list(rna_item.items()) items.sort() @@ -183,7 +183,7 @@ def draw(layout, context, context_member, property_type, *, use_edit=True): # Do not allow editing of overridden properties (we cannot use a poll function # of the operators here since they's have no access to the specific property). - operator_row.enabled = not(is_lib_override and key in rna_item.id_data.override_library.reference) + operator_row.enabled = not (is_lib_override and key in rna_item.id_data.override_library.reference) if use_edit: if is_rna: diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index c8569990a3a..75d0717184e 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -128,7 +128,7 @@ class Params: self.legacy = legacy if use_mouse_emulate_3_button: - assert(use_alt_tool_or_cursor is False) + assert use_alt_tool_or_cursor is False if select_mouse == 'RIGHT': # Right mouse select. diff --git a/release/scripts/startup/bl_operators/uvcalc_follow_active.py b/release/scripts/startup/bl_operators/uvcalc_follow_active.py index a5c91f238d2..f9f8d7d1019 100644 --- a/release/scripts/startup/bl_operators/uvcalc_follow_active.py +++ b/release/scripts/startup/bl_operators/uvcalc_follow_active.py @@ -229,7 +229,7 @@ def main(context, operator): elif status & STATUS_ERR_NOT_SELECTED: operator.report({'ERROR'}, "Active face not selected") else: - assert((status & STATUS_ERR_ACTIVE_FACE) != 0) + assert status & STATUS_ERR_ACTIVE_FACE != 0 operator.report({'ERROR'}, "No active face") diff --git a/release/scripts/startup/bl_operators/uvcalc_lightmap.py b/release/scripts/startup/bl_operators/uvcalc_lightmap.py index 93c72c97129..995ec721046 100644 --- a/release/scripts/startup/bl_operators/uvcalc_lightmap.py +++ b/release/scripts/startup/bl_operators/uvcalc_lightmap.py @@ -452,7 +452,7 @@ def lightmap_uvpack( pretty_faces.append(pf_parent) w, h = pf_parent.width, pf_parent.height - assert(w <= h) + assert w <= h if w == h: even_dict.setdefault(w, []).append(pf_parent) diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py index cbb5a63b754..f8cb57d638a 100644 --- a/release/scripts/startup/bl_operators/wm.py +++ b/release/scripts/startup/bl_operators/wm.py @@ -178,10 +178,10 @@ def context_path_decompose(data_path): prop_item = "".join(path_split[i + 1:]) if base_path: - assert(base_path.startswith(".")) + assert base_path.startswith(".") base_path = base_path[1:] if prop_attr: - assert(prop_attr.startswith(".")) + assert prop_attr.startswith(".") prop_attr = prop_attr[1:] else: # If there are no properties, everything is an item. @@ -2730,7 +2730,7 @@ class WM_OT_batch_rename(Operator): elif method == 'SUFFIX': name = name + text else: - assert(0) + assert 0 elif ty == 'STRIP': chars = action.strip_chars @@ -2775,9 +2775,9 @@ class WM_OT_batch_rename(Operator): elif method == 'TITLE': name = name.title() else: - assert(0) + assert 0 else: - assert(0) + assert 0 return name def _data_update(self, context): diff --git a/release/scripts/startup/bl_ui/space_toolsystem_common.py b/release/scripts/startup/bl_ui/space_toolsystem_common.py index 39dfdd0eecb..81acc0837aa 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_common.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_common.py @@ -232,7 +232,7 @@ class ToolSelectPanelHelper: def _icon_value_from_icon_handle(icon_name): import os if icon_name is not None: - assert(type(icon_name) is str) + assert type(icon_name) is str icon_value = _icon_cache.get(icon_name) if icon_value is None: dirname = bpy.utils.system_resource('DATAFILES', path="icons") diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index d15be4a9d3f..78e7932433e 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1917,7 +1917,7 @@ class VIEW3D_PT_tools_grease_pencil_sculpt_select(Panel, View3DPanel, GreasePenc if brush is not None: col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") - if(brush.use_custom_icon): + if (brush.use_custom_icon): layout.row().prop(brush, "icon_filepath", text="") @@ -2026,7 +2026,7 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint_select(View3DPanel, Panel, Grea if brush is not None: col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") - if(brush.use_custom_icon): + if (brush.use_custom_icon): layout.row().prop(brush, "icon_filepath", text="") @@ -2101,7 +2101,7 @@ class VIEW3D_PT_tools_grease_pencil_vertex_paint_select(View3DPanel, Panel, Grea if brush is not None: col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="") - if(brush.use_custom_icon): + if (brush.use_custom_icon): layout.row().prop(brush, "icon_filepath", text="") diff --git a/source/blender/datatoc/datatoc_icon.py b/source/blender/datatoc/datatoc_icon.py index 7373df71318..84cef0457a6 100755 --- a/source/blender/datatoc/datatoc_icon.py +++ b/source/blender/datatoc/datatoc_icon.py @@ -75,8 +75,8 @@ def icon_merge(file_src, pixels_canvas, canvas_w, canvas_h): orig_x, orig_y, w_canvas_test, h_canvas_test) = head - assert(w_canvas_test == canvas_w) - assert(h_canvas_test == canvas_h) + assert w_canvas_test == canvas_w + assert h_canvas_test == canvas_h for x in range(icon_w): for y in range(icon_h): diff --git a/tests/python/bl_blendfile_io.py b/tests/python/bl_blendfile_io.py index f79ee2a240b..fa63b789751 100644 --- a/tests/python/bl_blendfile_io.py +++ b/tests/python/bl_blendfile_io.py @@ -33,7 +33,7 @@ class TestBlendFileSaveLoadBasic(TestHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data 1") # We have orphaned data, which should be removed by file reading, so there should not be equality here. - assert(orig_data != read_data) + assert orig_data != read_data bpy.data.orphans_purge() @@ -44,7 +44,7 @@ class TestBlendFileSaveLoadBasic(TestHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data 2") - assert(orig_data == read_data) + assert orig_data == read_data TESTS = ( diff --git a/tests/python/bl_blendfile_liblink.py b/tests/python/bl_blendfile_liblink.py index 120afba4911..a4ca845da4e 100644 --- a/tests/python/bl_blendfile_liblink.py +++ b/tests/python/bl_blendfile_liblink.py @@ -93,9 +93,9 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Mesh") bpy.ops.wm.link(directory=link_dir, filename="LibMesh", instance_object_data=False) - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 0) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 0 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -106,8 +106,8 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data") # Since there is no usage of linked mesh, it is lost during save/reload. - assert(len(bpy.data.meshes) == 0) - assert(orig_data != read_data) + assert len(bpy.data.meshes) == 0 + assert orig_data != read_data # Simple link of a single ObData with obdata instantiation. self.reset_blender() @@ -115,9 +115,9 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Mesh") bpy.ops.wm.link(directory=link_dir, filename="LibMesh", instance_object_data=True) - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 1) # Instance created for the mesh ObData. - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 1 # Instance created for the mesh ObData. + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -126,7 +126,7 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data") - assert(orig_data == read_data) + assert orig_data == read_data # Simple link of a single Object. self.reset_blender() @@ -134,9 +134,9 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Object") bpy.ops.wm.link(directory=link_dir, filename="LibMesh") - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 1) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 1 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -145,7 +145,7 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data") - assert(orig_data == read_data) + assert orig_data == read_data # Simple link of a single Collection, with Empty-instantiation. self.reset_blender() @@ -153,9 +153,9 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Collection") bpy.ops.wm.link(directory=link_dir, filename="LibMesh", instance_collections=True) - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 2) # linked object and local empty instancing the collection - assert(len(bpy.data.collections) == 1) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 2 # linked object and local empty instancing the collection + assert len(bpy.data.collections) == 1 # Scene's master collection is not listed here orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -164,7 +164,7 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data") - assert(orig_data == read_data) + assert orig_data == read_data # Simple link of a single Collection, with ViewLayer-instantiation. self.reset_blender() @@ -172,11 +172,11 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Collection") bpy.ops.wm.link(directory=link_dir, filename="LibMesh", instance_collections=False) - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 1) - assert(len(bpy.data.collections) == 1) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 1 + assert len(bpy.data.collections) == 1 # Scene's master collection is not listed here # Linked collection should have been added to the scene's master collection children. - assert(bpy.data.collections[0] in set(bpy.data.scenes[0].collection.children)) + assert bpy.data.collections[0] in set(bpy.data.scenes[0].collection.children) orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -185,7 +185,7 @@ class TestBlendLibLinkSaveLoadBasic(TestBlendLibLinkHelper): read_data = self.blender_data_to_tuple(bpy.data, "read_data") - assert(orig_data == read_data) + assert orig_data == read_data class TestBlendLibAppendBasic(TestBlendLibLinkHelper): @@ -211,15 +211,15 @@ class TestBlendLibAppendBasic(TestBlendLibLinkHelper): bpy.data.materials[0].use_fake_user, ) - assert(len(bpy.data.materials) == 1) - assert(bpy.data.materials[0].library is not None) - assert(bpy.data.materials[0].users == 2) # Fake user is not cleared when linking. - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].use_fake_user is False) - assert(bpy.data.meshes[0].users == 0) - assert(len(bpy.data.objects) == 0) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.materials) == 1 + assert bpy.data.materials[0].library is not None + assert bpy.data.materials[0].users == 2 # Fake user is not cleared when linking. + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].use_fake_user is False + assert bpy.data.meshes[0].users == 0 + assert len(bpy.data.objects) == 0 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here # Simple append of a single ObData with obdata instantiation. self.reset_blender() @@ -228,16 +228,16 @@ class TestBlendLibAppendBasic(TestBlendLibLinkHelper): bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=True, set_fake=False, use_recursive=False, do_reuse_local_id=False) - assert(len(bpy.data.materials) == 1) - assert(bpy.data.materials[0].library is not None) - assert(bpy.data.materials[0].users == 2) # Fake user is not cleared when linking. - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].use_fake_user is False) - assert(bpy.data.meshes[0].users == 1) - assert(len(bpy.data.objects) == 1) # Instance created for the mesh ObData. - assert(bpy.data.objects[0].library is None) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.materials) == 1 + assert bpy.data.materials[0].library is not None + assert bpy.data.materials[0].users == 2 # Fake user is not cleared when linking. + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].use_fake_user is False + assert bpy.data.meshes[0].users == 1 + assert len(bpy.data.objects) == 1 # Instance created for the mesh ObData. + assert bpy.data.objects[0].library is None + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here # Simple append of a single ObData with fake user. self.reset_blender() @@ -246,15 +246,15 @@ class TestBlendLibAppendBasic(TestBlendLibLinkHelper): bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=True, use_recursive=False, do_reuse_local_id=False) - assert(len(bpy.data.materials) == 1) - assert(bpy.data.materials[0].library is not None) - assert(bpy.data.materials[0].users == 2) # Fake user is not cleared when linking. - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].use_fake_user is True) - assert(bpy.data.meshes[0].users == 1) - assert(len(bpy.data.objects) == 0) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.materials) == 1 + assert bpy.data.materials[0].library is not None + assert bpy.data.materials[0].users == 2 # Fake user is not cleared when linking. + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].use_fake_user is True + assert bpy.data.meshes[0].users == 1 + assert len(bpy.data.objects) == 0 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here # Simple append of a single Object. self.reset_blender() @@ -263,16 +263,16 @@ class TestBlendLibAppendBasic(TestBlendLibLinkHelper): bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=False, use_recursive=False, do_reuse_local_id=False) - assert(len(bpy.data.materials) == 1) - assert(bpy.data.materials[0].library is not None) - assert(bpy.data.materials[0].users == 2) # Fake user is not cleared when linking. - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].users == 1) - assert(len(bpy.data.objects) == 1) - assert(bpy.data.objects[0].library is None) - assert(bpy.data.objects[0].users == 1) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.materials) == 1 + assert bpy.data.materials[0].library is not None + assert bpy.data.materials[0].users == 2 # Fake user is not cleared when linking. + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].users == 1 + assert len(bpy.data.objects) == 1 + assert bpy.data.objects[0].library is None + assert bpy.data.objects[0].users == 1 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here # Simple recursive append of a single Object. self.reset_blender() @@ -281,16 +281,16 @@ class TestBlendLibAppendBasic(TestBlendLibLinkHelper): bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=False, use_recursive=True, do_reuse_local_id=False) - assert(len(bpy.data.materials) == 1) - assert(bpy.data.materials[0].library is None) - assert(bpy.data.materials[0].users == 1) # Fake user is cleared when appending. - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].users == 1) - assert(len(bpy.data.objects) == 1) - assert(bpy.data.objects[0].library is None) - assert(bpy.data.objects[0].users == 1) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.materials) == 1 + assert bpy.data.materials[0].library is None + assert bpy.data.materials[0].users == 1 # Fake user is cleared when appending. + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].users == 1 + assert len(bpy.data.objects) == 1 + assert bpy.data.objects[0].library is None + assert bpy.data.objects[0].users == 1 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here # Simple recursive append of a single Collection. self.reset_blender() @@ -299,17 +299,17 @@ class TestBlendLibAppendBasic(TestBlendLibLinkHelper): bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=False, use_recursive=True, do_reuse_local_id=False) - assert(len(bpy.data.materials) == 1) - assert(bpy.data.materials[0].library is None) - assert(bpy.data.materials[0].users == 1) # Fake user is cleared when appending. - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].users == 1) - assert(len(bpy.data.objects) == 1) - assert(bpy.data.objects[0].library is None) - assert(bpy.data.objects[0].users == 1) - assert(len(bpy.data.collections) == 1) # Scene's master collection is not listed here - assert(bpy.data.collections[0].library is None) - assert(bpy.data.collections[0].users == 1) + assert len(bpy.data.materials) == 1 + assert bpy.data.materials[0].library is None + assert bpy.data.materials[0].users == 1 # Fake user is cleared when appending. + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].users == 1 + assert len(bpy.data.objects) == 1 + assert bpy.data.objects[0].library is None + assert bpy.data.objects[0].users == 1 + assert len(bpy.data.collections) == 1 # Scene's master collection is not listed here + assert bpy.data.collections[0].library is None + assert bpy.data.collections[0].users == 1 class TestBlendLibAppendReuseID(TestBlendLibLinkHelper): @@ -328,51 +328,51 @@ class TestBlendLibAppendReuseID(TestBlendLibLinkHelper): bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=False, use_recursive=True, do_reuse_local_id=False) - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].use_fake_user is False) - assert(bpy.data.meshes[0].users == 1) - assert(bpy.data.meshes[0].library_weak_reference is not None) - assert(bpy.data.meshes[0].library_weak_reference.filepath == output_lib_path) - assert(bpy.data.meshes[0].library_weak_reference.id_name == "MELibMesh") - assert(len(bpy.data.objects) == 1) + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].use_fake_user is False + assert bpy.data.meshes[0].users == 1 + assert bpy.data.meshes[0].library_weak_reference is not None + assert bpy.data.meshes[0].library_weak_reference.filepath == output_lib_path + assert bpy.data.meshes[0].library_weak_reference.id_name == "MELibMesh" + assert len(bpy.data.objects) == 1 for ob in bpy.data.objects: - assert(ob.library is None) - assert(ob.library_weak_reference is None) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert ob.library is None + assert ob.library_weak_reference is None + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=False, use_recursive=True, do_reuse_local_id=True) - assert(len(bpy.data.meshes) == 1) - assert(bpy.data.meshes[0].library is None) - assert(bpy.data.meshes[0].use_fake_user is False) - assert(bpy.data.meshes[0].users == 2) - assert(bpy.data.meshes[0].library_weak_reference is not None) - assert(bpy.data.meshes[0].library_weak_reference.filepath == output_lib_path) - assert(bpy.data.meshes[0].library_weak_reference.id_name == "MELibMesh") - assert(len(bpy.data.objects) == 2) + assert len(bpy.data.meshes) == 1 + assert bpy.data.meshes[0].library is None + assert bpy.data.meshes[0].use_fake_user is False + assert bpy.data.meshes[0].users == 2 + assert bpy.data.meshes[0].library_weak_reference is not None + assert bpy.data.meshes[0].library_weak_reference.filepath == output_lib_path + assert bpy.data.meshes[0].library_weak_reference.id_name == "MELibMesh" + assert len(bpy.data.objects) == 2 for ob in bpy.data.objects: - assert(ob.library is None) - assert(ob.library_weak_reference is None) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert ob.library is None + assert ob.library_weak_reference is None + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here bpy.ops.wm.append(directory=link_dir, filename="LibMesh", instance_object_data=False, set_fake=False, use_recursive=True, do_reuse_local_id=False) - assert(len(bpy.data.meshes) == 2) - assert(bpy.data.meshes[0].library_weak_reference is None) - assert(bpy.data.meshes[1].library is None) - assert(bpy.data.meshes[1].use_fake_user is False) - assert(bpy.data.meshes[1].users == 1) - assert(bpy.data.meshes[1].library_weak_reference is not None) - assert(bpy.data.meshes[1].library_weak_reference.filepath == output_lib_path) - assert(bpy.data.meshes[1].library_weak_reference.id_name == "MELibMesh") - assert(len(bpy.data.objects) == 3) + assert len(bpy.data.meshes) == 2 + assert bpy.data.meshes[0].library_weak_reference is None + assert bpy.data.meshes[1].library is None + assert bpy.data.meshes[1].use_fake_user is False + assert bpy.data.meshes[1].users == 1 + assert bpy.data.meshes[1].library_weak_reference is not None + assert bpy.data.meshes[1].library_weak_reference.filepath == output_lib_path + assert bpy.data.meshes[1].library_weak_reference.id_name == "MELibMesh" + assert len(bpy.data.objects) == 3 for ob in bpy.data.objects: - assert(ob.library is None) - assert(ob.library_weak_reference is None) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert ob.library is None + assert ob.library_weak_reference is None + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here class TestBlendLibLibraryReload(TestBlendLibLinkHelper): @@ -390,9 +390,9 @@ class TestBlendLibLibraryReload(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Object") bpy.ops.wm.link(directory=link_dir, filename="LibMesh") - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 1) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 1 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -402,7 +402,7 @@ class TestBlendLibLibraryReload(TestBlendLibLinkHelper): print(orig_data) print(reload_data) - assert(orig_data == reload_data) + assert orig_data == reload_data class TestBlendLibLibraryRelocate(TestBlendLibLinkHelper): @@ -420,9 +420,9 @@ class TestBlendLibLibraryRelocate(TestBlendLibLinkHelper): link_dir = os.path.join(output_lib_path, "Object") bpy.ops.wm.link(directory=link_dir, filename="LibMesh") - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 1) - assert(len(bpy.data.collections) == 0) # Scene's master collection is not listed here + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 1 + assert len(bpy.data.collections) == 0 # Scene's master collection is not listed here orig_data = self.blender_data_to_tuple(bpy.data, "orig_data") @@ -436,7 +436,7 @@ class TestBlendLibLibraryRelocate(TestBlendLibLinkHelper): print(orig_data) print(relocate_data) - assert(orig_data == relocate_data) + assert orig_data == relocate_data class TestBlendLibDataLibrariesLoad(TestBlendLibLinkHelper): @@ -454,21 +454,21 @@ class TestBlendLibDataLibrariesLoad(TestBlendLibLinkHelper): with bpy.data.libraries.load(filepath=output_lib_path) as lib_ctx: lib_src, lib_link = lib_ctx - assert(len(lib_src.meshes) == 1) - assert(len(lib_src.objects) == 1) - assert(len(lib_src.collections) == 1) + assert len(lib_src.meshes) == 1 + assert len(lib_src.objects) == 1 + assert len(lib_src.collections) == 1 - assert(len(lib_link.meshes) == 0) - assert(len(lib_link.objects) == 0) - assert(len(lib_link.collections) == 0) + assert len(lib_link.meshes) == 0 + assert len(lib_link.objects) == 0 + assert len(lib_link.collections) == 0 lib_link.collections.append(lib_src.collections[0]) # Linking happens when living the context manager. - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.objects) == 1) # This code does no instantiation. - assert(len(bpy.data.collections) == 1) + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.objects) == 1 # This code does no instantiation. + assert len(bpy.data.collections) == 1 TESTS = ( diff --git a/tests/python/bl_blendfile_library_overrides.py b/tests/python/bl_blendfile_library_overrides.py index 3ba99bd61e4..6890bb1e660 100644 --- a/tests/python/bl_blendfile_library_overrides.py +++ b/tests/python/bl_blendfile_library_overrides.py @@ -57,49 +57,49 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): local_id = obj.override_create() self.assertIsNotNone(local_id.override_library) self.assertIsNone(local_id.data.override_library) - assert(len(local_id.override_library.properties) == 0) + assert len(local_id.override_library.properties) == 0 # #### Generate an override property & operation automatically by editing the local override data. local_id.location.y = 1.0 local_id.override_library.operations_update() - assert(len(local_id.override_library.properties) == 1) + assert len(local_id.override_library.properties) == 1 override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "location") - assert(len(override_prop.operations) == 1) + assert override_prop.rna_path == "location" + assert len(override_prop.operations) == 1 override_operation = override_prop.operations[0] - assert(override_operation.operation == 'REPLACE') + assert override_operation.operation == 'REPLACE' # Setting location.y overrode all elements in the location array. -1 is a wildcard. - assert(override_operation.subitem_local_index == -1) + assert override_operation.subitem_local_index == -1 # #### Reset the override to its linked reference data. local_id.override_library.reset() - assert(len(local_id.override_library.properties) == 0) - assert(local_id.location == local_id.override_library.reference.location) + assert len(local_id.override_library.properties) == 0 + assert local_id.location == local_id.override_library.reference.location # #### Generate an override property & operation manually using the API. override_property = local_id.override_library.properties.add(rna_path="location") override_property.operations.add(operation='REPLACE') - assert(len(local_id.override_library.properties) == 1) + assert len(local_id.override_library.properties) == 1 override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "location") - assert(len(override_prop.operations) == 1) + assert override_prop.rna_path == "location" + assert len(override_prop.operations) == 1 override_operation = override_prop.operations[0] - assert(override_operation.operation == 'REPLACE') + assert override_operation.operation == 'REPLACE' # Setting location.y overrode all elements in the location array. -1 is a wildcard. - assert(override_operation.subitem_local_index == -1) + assert override_operation.subitem_local_index == -1 override_property = local_id.override_library.properties[0] override_property.operations.remove(override_property.operations[0]) local_id.override_library.properties.remove(override_property) - assert(len(local_id.override_library.properties) == 0) + assert len(local_id.override_library.properties) == 0 # #### Delete the override. local_id_name = local_id.name - assert(bpy.data.objects.get((local_id_name, None), None) == local_id) + assert bpy.data.objects.get((local_id_name, None), None) == local_id local_id.override_library.destroy() - assert(bpy.data.objects.get((local_id_name, None), None) is None) + assert bpy.data.objects.get((local_id_name, None), None) is None def test_link_permissive(self): """ @@ -119,39 +119,39 @@ class TestLibraryOverrides(TestHelper, unittest.TestCase): local_id = obj.override_create() self.assertIsNotNone(local_id.override_library) self.assertIsNone(local_id.data.override_library) - assert(len(local_id.override_library.properties) == 1) + assert len(local_id.override_library.properties) == 1 override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "scale") - assert(len(override_prop.operations) == 1) + assert override_prop.rna_path == "scale" + assert len(override_prop.operations) == 1 override_operation = override_prop.operations[0] - assert(override_operation.operation == 'NOOP') - assert(override_operation.subitem_local_index == -1) + assert override_operation.operation == 'NOOP' + assert override_operation.subitem_local_index == -1 local_id.location.y = 1.0 local_id.scale.x = 0.5 # `scale.x` will apply, but will be reverted when the library overrides # are updated. This is by design so python scripts can still alter the # properties locally what is a typical usecase in productions. - assert(local_id.scale.x == 0.5) - assert(local_id.location.y == 1.0) + assert local_id.scale.x == 0.5 + assert local_id.location.y == 1.0 local_id.override_library.operations_update() - assert(local_id.scale.x == 1.0) - assert(local_id.location.y == 1.0) + assert local_id.scale.x == 1.0 + assert local_id.location.y == 1.0 - assert(len(local_id.override_library.properties) == 2) + assert len(local_id.override_library.properties) == 2 override_prop = local_id.override_library.properties[0] - assert(override_prop.rna_path == "scale") - assert(len(override_prop.operations) == 1) + assert override_prop.rna_path == "scale" + assert len(override_prop.operations) == 1 override_operation = override_prop.operations[0] - assert(override_operation.operation == 'NOOP') - assert(override_operation.subitem_local_index == -1) + assert override_operation.operation == 'NOOP' + assert override_operation.subitem_local_index == -1 override_prop = local_id.override_library.properties[1] - assert(override_prop.rna_path == "location") - assert(len(override_prop.operations) == 1) + assert override_prop.rna_path == "location" + assert len(override_prop.operations) == 1 override_operation = override_prop.operations[0] - assert(override_operation.operation == 'REPLACE') - assert (override_operation.subitem_local_index == -1) + assert override_operation.operation == 'REPLACE' + assert override_operation.subitem_local_index == -1 class TestLibraryTemplate(TestHelper, unittest.TestCase): @@ -169,16 +169,16 @@ class TestLibraryTemplate(TestHelper, unittest.TestCase): mesh = bpy.data.meshes.new(TestLibraryTemplate.MESH_LIBRARY_PERMISSIVE) obj = bpy.data.objects.new(TestLibraryTemplate.OBJECT_LIBRARY_PERMISSIVE, object_data=mesh) bpy.context.collection.objects.link(obj) - assert(obj.override_library is None) + assert obj.override_library is None obj.override_template_create() - assert(obj.override_library is not None) - assert(len(obj.override_library.properties) == 0) + assert obj.override_library is not None + assert len(obj.override_library.properties) == 0 prop = obj.override_library.properties.add(rna_path='scale') - assert(len(obj.override_library.properties) == 1) - assert(len(prop.operations) == 0) + assert len(obj.override_library.properties) == 1 + assert len(prop.operations) == 0 operation = prop.operations.add(operation='NOOP') - assert(len(prop.operations) == 1) - assert(operation.operation == 'NOOP') + assert len(prop.operations) == 1 + assert operation.operation == 'NOOP' class TestLibraryOverridesResync(TestHelper, unittest.TestCase): @@ -237,30 +237,30 @@ class TestLibraryOverridesResync(TestHelper, unittest.TestCase): ) linked_collection_container = bpy.data.collections[TestLibraryOverridesResync.DATA_NAME_CONTAINER] - assert(linked_collection_container.library is not None) - assert(linked_collection_container.override_library is None) - assert(len(bpy.data.collections) == 2) - assert(all(id_.library is not None for id_ in bpy.data.collections)) - assert(len(bpy.data.objects) == 4) - assert(all(id_.library is not None for id_ in bpy.data.objects)) - assert(len(bpy.data.meshes) == 1) - assert(all(id_.library is not None for id_ in bpy.data.meshes)) - assert(len(bpy.data.armatures) == 1) - assert(all(id_.library is not None for id_ in bpy.data.armatures)) + assert linked_collection_container.library is not None + assert linked_collection_container.override_library is None + assert len(bpy.data.collections) == 2 + assert all(id_.library is not None for id_ in bpy.data.collections) + assert len(bpy.data.objects) == 4 + assert all(id_.library is not None for id_ in bpy.data.objects) + assert len(bpy.data.meshes) == 1 + assert all(id_.library is not None for id_ in bpy.data.meshes) + assert len(bpy.data.armatures) == 1 + assert all(id_.library is not None for id_ in bpy.data.armatures) override_collection_container = linked_collection_container.override_hierarchy_create( bpy.context.scene, bpy.context.view_layer, ) - assert(override_collection_container.library is None) - assert(override_collection_container.override_library is not None) + assert override_collection_container.library is None + assert override_collection_container.override_library is not None # Objects and collections are duplicated as overrides, but meshes and armatures remain only linked data. - assert(len(bpy.data.collections) == 4) - assert(all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.collections[:2])) - assert(len(bpy.data.objects) == 8) - assert(all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.objects[:4])) - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.armatures) == 1) + assert len(bpy.data.collections) == 4 + assert all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.collections[:2]) + assert len(bpy.data.objects) == 8 + assert all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.objects[:4]) + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.armatures) == 1 bpy.ops.wm.save_as_mainfile(filepath=str(self.test_output_path), check_existing=False, compress=False) @@ -279,21 +279,21 @@ class TestLibraryOverridesResync(TestHelper, unittest.TestCase): bpy.ops.wm.open_mainfile(filepath=str(self.test_output_path)) override_collection_container = bpy.data.collections[TestLibraryOverridesResync.DATA_NAME_CONTAINER] - assert(override_collection_container.library is None) - assert(override_collection_container.override_library is not None) + assert override_collection_container.library is None + assert override_collection_container.override_library is not None # Objects and collections are duplicated as overrides, but meshes and armatures remain only linked data. - assert(len(bpy.data.collections) == 4) - assert(all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.collections[:2])) - assert(len(bpy.data.objects) == 8) - assert(all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.objects[:4])) - assert(len(bpy.data.meshes) == 1) - assert(len(bpy.data.armatures) == 1) + assert len(bpy.data.collections) == 4 + assert all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.collections[:2]) + assert len(bpy.data.objects) == 8 + assert all((id_.library is None and id_.override_library is not None) for id_ in bpy.data.objects[:4]) + assert len(bpy.data.meshes) == 1 + assert len(bpy.data.armatures) == 1 obj_armature = bpy.data.objects[TestLibraryOverridesResync.DATA_NAME_RIG] obj_ctrl2 = bpy.data.objects[TestLibraryOverridesResync.DATA_NAME_CONTROLLER_2] - assert(obj_armature.library is None and obj_armature.override_library is not None) - assert(obj_ctrl2.library is None and obj_ctrl2.override_library is not None) - assert(obj_armature.constraints[0].target == obj_ctrl2) + assert obj_armature.library is None and obj_armature.override_library is not None + assert obj_ctrl2.library is None and obj_ctrl2.override_library is not None + assert obj_armature.constraints[0].target == obj_ctrl2 TESTS = ( diff --git a/tests/python/bl_keymap_validate.py b/tests/python/bl_keymap_validate.py index 83d41c8a9f6..11da4d562b0 100644 --- a/tests/python/bl_keymap_validate.py +++ b/tests/python/bl_keymap_validate.py @@ -228,7 +228,7 @@ def keyconfig_activate_and_extract_data( bpy.ops.preferences.keyconfig_activate(filepath=filepath) # If called multiple times, something strange is happening. - assert(len(args_collected) == 1) + assert len(args_collected) == 1 args, _kw = args_collected[0] # Ignore the type check as `temp_fn_argument_extractor` is a generic function # which doesn't contain type information of the function being wrapped. diff --git a/tests/python/bl_load_addons.py b/tests/python/bl_load_addons.py index b94c56541af..b67bc22102c 100644 --- a/tests/python/bl_load_addons.py +++ b/tests/python/bl_load_addons.py @@ -57,7 +57,7 @@ def disable_addons(): addons = bpy.context.preferences.addons for mod_name in list(addons.keys()): addon_utils.disable(mod_name, default_set=True) - assert(bool(addons) is False) + assert bool(addons) is False def test_load_addons(): @@ -97,13 +97,13 @@ def reload_addons(do_reload=True, do_reverse=True): mod_name = mod.__name__ print("\tenabling:", mod_name) addon_utils.enable(mod_name, default_set=True) - assert(mod_name in addons) + assert mod_name in addons for mod in modules: mod_name = mod.__name__ print("\tdisabling:", mod_name) addon_utils.disable(mod_name, default_set=True) - assert(not (mod_name in addons)) + assert not (mod_name in addons) # now test reloading if do_reload: diff --git a/tests/python/bl_load_py_modules.py b/tests/python/bl_load_py_modules.py index 7ad5895ce86..784d8984935 100644 --- a/tests/python/bl_load_py_modules.py +++ b/tests/python/bl_load_py_modules.py @@ -161,7 +161,7 @@ def load_modules(): sys.path[:] = sys_path_back # check we load what we ask for. - assert(os.path.samefile(mod_imp.__file__, submod_full)) + assert os.path.samefile(mod_imp.__file__, submod_full) modules.append(mod_imp) except Exception: diff --git a/tests/python/bl_mesh_modifiers.py b/tests/python/bl_mesh_modifiers.py index 640cf1c30f2..5498316b267 100644 --- a/tests/python/bl_mesh_modifiers.py +++ b/tests/python/bl_mesh_modifiers.py @@ -55,8 +55,8 @@ def render_gl(context, filepath, shade): def render_gl_all_modes(context, obj, filepath=""): - assert(obj is not None) - assert(filepath != "") + assert obj is not None + assert filepath != "" scene = context.scene @@ -91,7 +91,7 @@ def render_gl_all_modes(context, obj, filepath=""): render_gl(context, filepath + "_wp_wire", shade='WIREFRAME') - assert(1) + assert 1 bpy.ops.object.mode_set(mode='OBJECT', toggle=False) diff --git a/tests/python/bl_pyapi_idprop.py b/tests/python/bl_pyapi_idprop.py index ddb5be03594..ddce132dd5a 100644 --- a/tests/python/bl_pyapi_idprop.py +++ b/tests/python/bl_pyapi_idprop.py @@ -22,7 +22,7 @@ class TestHelper: def setUp(self): self._id = bpy.context.scene self._id.pop("cycles", None) - assert(len(self._id.keys()) == 0) + assert len(self._id.keys()) == 0 def tearDown(self): for key in list(self._id.keys()): diff --git a/tests/python/bl_rna_manual_reference.py b/tests/python/bl_rna_manual_reference.py index 257c8b7601a..958cc46ae29 100644 --- a/tests/python/bl_rna_manual_reference.py +++ b/tests/python/bl_rna_manual_reference.py @@ -15,12 +15,12 @@ import bpy def test_data(): import rna_manual_reference - assert(isinstance(rna_manual_reference.url_manual_mapping, tuple)) + assert isinstance(rna_manual_reference.url_manual_mapping, tuple) for i, value in enumerate(rna_manual_reference.url_manual_mapping): try: - assert(len(value) == 2) - assert(isinstance(value[0], str)) - assert(isinstance(value[1], str)) + assert len(value) == 2 + assert isinstance(value[0], str) + assert isinstance(value[1], str) except: print("Expected a tuple of 2 strings, instead item %d is a %s: %r" % (i, type(value), value)) import traceback diff --git a/tests/python/bl_run_operators_event_simulate.py b/tests/python/bl_run_operators_event_simulate.py index d218e6b1bc0..e17eaef0480 100644 --- a/tests/python/bl_run_operators_event_simulate.py +++ b/tests/python/bl_run_operators_event_simulate.py @@ -461,7 +461,7 @@ class BlenderAction(argparse.Action): except ArgumentTypeError as ex: raise ArgumentTypeError("Invalid 'action' arguments \"%s\" at index %d, %s" % (value, index, str(ex))) # Validation should never yield any events. - assert(not dummy_result) + assert not dummy_result return (op, args, kwargs) -- cgit v1.2.3