Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Blender 3.4 tests #4844

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions old_nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,22 @@ def has_old_nodes(tree) -> bool:

def register_old(bl_id):
"""Register old node class"""
if bl_id in old_bl_idnames:
mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__)
res = inspect.getmembers(mod)
for name, cls in res:
if inspect.isclass(cls):
if issubclass(cls, bpy.types.Node) and cls.bl_idname == bl_id:
if bl_id not in imported_mods:
mod.register()
imported_mods[bl_id] = mod
else:
if bl_id in imported_mods:
return
if bl_id not in old_bl_idnames:
raise LookupError(f"Cannot find {bl_id} among old nodes")
mod = importlib.import_module(".{}".format(old_bl_idnames[bl_id]), __name__)
res = inspect.getmembers(mod)
module_node_bl_idnames = set() # there can be multiple of them
for name, cls in res:
if inspect.isclass(cls):
if issubclass(cls, bpy.types.Node):
module_node_bl_idnames.add(cls.bl_idname)
if bl_id not in module_node_bl_idnames:
raise LookupError(f"Old_bl_idnames returns something wrong for {bl_id=}")
mod.register()
for bl_idname in module_node_bl_idnames:
imported_mods[bl_idname] = mod


def register_all():
Expand Down
2 changes: 1 addition & 1 deletion tests/group_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_grouping_nodes(self):
importer.import_into_tree(new_tree, print_log=False)
[setattr(n, 'select', False) for n in new_tree.nodes]
[setattr(new_tree.nodes[n], 'select', True) for n in ['A Number', 'Formula',
'Vector polar input', 'Vector polar output']]
'Vector Polar Input', 'Vector Polar Output']]
with self.subTest(msg="Grouping nodes"):
bpy.ops.node.add_group_tree_from_selected()
with self.subTest(msg="Ungrouping nodes"):
Expand Down
2 changes: 1 addition & 1 deletion ui/testing_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def execute(self, context):
# making self.report after all tests lead to strange error, so no report for testing all
test.run_all_tests()
else:
test_result = test.run_test_from_file(self.test_module + '.py')
test_result = test.run_all_tests(self.test_module + '.py')
self.report(type={'ERROR'} if test_result != 'OK' else {'INFO'}, message=test_result)
return {'FINISHED'}

Expand Down
22 changes: 12 additions & 10 deletions utils/sv_json_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,19 +648,21 @@ def build(self, node, factories: StructFactory, imported_data: OldNewNames):
# it will cause replacing of all sockets with wrong identifiers in the group node.
# clearing and adding sockets of Group input and Group output nodes
# immediately cause their rebuilding by Blender, so JSON file does not save information about their sockets.
if node.bl_idname not in {'NodeGroupInput', 'NodeGroupOutput'}:
build_in_id_names = {
'NodeGroupInput', 'NodeGroupOutput', 'NodeFrame', 'NodeReroute'}
if node.bl_idname not in build_in_id_names:
node.inputs.clear()
for sock_identifier, raw_struct in self._struct.get("inputs", dict()).items():
with self.logger.add_fail("Add in socket",
f"Tree: {node.id_data.name}, Node {node.name}, Sock: {sock_identifier}"):
factories.sock(sock_identifier, self.logger, raw_struct).build(node.inputs, factories, imported_data)
for sock_identifier, raw_struct in self._struct.get("inputs", dict()).items():
with self.logger.add_fail("Add in socket",
f"Tree: {node.id_data.name}, Node {node.name}, Sock: {sock_identifier}"):
factories.sock(sock_identifier, self.logger, raw_struct).build(node.inputs, factories, imported_data)

if node.bl_idname not in {'NodeGroupInput', 'NodeGroupOutput'}:
if node.bl_idname not in build_in_id_names:
node.outputs.clear()
for sock_identifier, raw_struct in self._struct.get("outputs", dict()).items():
with self.logger.add_fail("Add out socket",
f"Tree: {node.id_data.name}, Node {node.name}, Sock: {sock_identifier}"):
factories.sock(sock_identifier, self.logger, raw_struct).build(node.outputs, factories, imported_data)
for sock_identifier, raw_struct in self._struct.get("outputs", dict()).items():
with self.logger.add_fail("Add out socket",
f"Tree: {node.id_data.name}, Node {node.name}, Sock: {sock_identifier}"):
factories.sock(sock_identifier, self.logger, raw_struct).build(node.outputs, factories, imported_data)

if hasattr(node, 'load_from_json'):
with self.logger.add_fail("Setting advance node properties",
Expand Down