Skip cleanup if there's only one single file #104582

Merged
Brecht Van Lommel merged 2 commits from Walles/blender-addons:johan/single-file into main 2023-06-27 10:14:13 +02:00
2 changed files with 33 additions and 1 deletions
Showing only changes of commit 88e4a02081 - Show all commits

View File

@ -103,7 +103,7 @@ def files_to_clean_file_names_for_sockets(files, sockets):
socket_tags = socket[1] socket_tags = socket[1]
all_tags.update(socket_tags) all_tags.update(socket_tags)
while True: while names_to_tag_lists and len(names_to_tag_lists) > 1:
Walles marked this conversation as resolved Outdated

I think this is testing for the same thing twice? This can't be None, and empty dictionaries return false.

I think this is testing for the same thing twice? This can't be None, and empty dictionaries return false.

Let's see.

The first part before and is true if the list is at least 1 long.

The second part after and is true if the list is at least 2 long.

And as you say, since the list is initialized to empty higher up and thus can't be None I believe you are right!

I'll fix this.

Let's see. The first part before `and` is true if the list is at least 1 long. The second part after `and` is true if the list is at least 2 long. And as you say, since the list is initialized to empty higher up and thus can't be `None` I believe you are right! I'll fix this.
something_changed = False something_changed = False
# Common prefixes / suffixes provide zero information about what file # Common prefixes / suffixes provide zero information about what file

View File

@ -255,6 +255,38 @@ class TestPutFileNamesInSockets(unittest.TestCase):
}, },
) )
def test_single_file_good(self):
"""Regression test for https://projects.blender.org/blender/blender-addons/issues/104573"""
files = [
MockFile("banana-color.webp"),
]
sockets = sockets_fixture()
match_files_to_socket_names(files, sockets)
assert_sockets(
self,
sockets,
{
"Base Color": "banana-color.webp",
},
)
def test_single_file_bad(self):
"""Regression test for https://projects.blender.org/blender/blender-addons/issues/104573"""
files = [
MockFile("README-banana.txt"),
]
sockets = sockets_fixture()
match_files_to_socket_names(files, sockets)
assert_sockets(
self,
sockets,
{},
)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main(verbosity=2) unittest.main(verbosity=2)