Fix tag homogenzation. Resolve #2524.

This commit is contained in:
Griatch 2022-01-08 16:57:18 +01:00
parent 3b5e20c4c2
commit 038c71213a
3 changed files with 36 additions and 10 deletions

View file

@ -139,11 +139,11 @@ def homogenize_prototype(prototype, custom_keys=None):
nattr = len(attr)
if nattr == 1:
# we assume a None-value
homogenized_attrs.append(attr[0], None, None, "")
homogenized_attrs.append((attr[0], None, None, ""))
elif nattr == 2:
homogenized_attrs.append(attr[0], attr[1], None, "")
homogenized_attrs.append((attr[0], attr[1], None, ""))
elif nattr == 3:
homogenized_attrs.append(attr[0], attr[1], attr[2], "")
homogenized_attrs.append((attr[0], attr[1], attr[2], ""))
else:
homogenized_attrs.append(attr[:4])

View file

@ -939,3 +939,25 @@ class Test2474(BaseEvenniaTest):
sting = spawner.spawn(self.prototypes["WEAPON"], prototype_parents=self.prototypes)[0]
self.assertEqual(sting.db.magic, False)
class TestPartialTagAttributes(BaseEvenniaTest):
"""
Make sure tags and attributes are homogenized if given as incomplete tuples.
See https://github.com/evennia/evennia/issues/2524.
"""
def setUp(self):
self.prot = {
'prototype_key': 'rock',
'typeclass': 'evennia.objects.objects.DefaultObject',
'key': 'a rock',
'tags': [('quantity', 'groupable')], # missing data field
'attrs': [('quantity', 1)], # missing category and lock fields
'desc': 'A good way to get stoned.'
}
def test_partial_spawn(self):
obj = spawner.spawn(self.prot)
self.assertEqual(obj[0].key, self.prot['key'])