Fix tag homogenzation. Resolve #2524.
This commit is contained in:
parent
3b5e20c4c2
commit
038c71213a
3 changed files with 36 additions and 10 deletions
|
|
@ -139,11 +139,11 @@ def homogenize_prototype(prototype, custom_keys=None):
|
||||||
nattr = len(attr)
|
nattr = len(attr)
|
||||||
if nattr == 1:
|
if nattr == 1:
|
||||||
# we assume a None-value
|
# we assume a None-value
|
||||||
homogenized_attrs.append(attr[0], None, None, "")
|
homogenized_attrs.append((attr[0], None, None, ""))
|
||||||
elif nattr == 2:
|
elif nattr == 2:
|
||||||
homogenized_attrs.append(attr[0], attr[1], None, "")
|
homogenized_attrs.append((attr[0], attr[1], None, ""))
|
||||||
elif nattr == 3:
|
elif nattr == 3:
|
||||||
homogenized_attrs.append(attr[0], attr[1], attr[2], "")
|
homogenized_attrs.append((attr[0], attr[1], attr[2], ""))
|
||||||
else:
|
else:
|
||||||
homogenized_attrs.append(attr[:4])
|
homogenized_attrs.append(attr[:4])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -939,3 +939,25 @@ class Test2474(BaseEvenniaTest):
|
||||||
sting = spawner.spawn(self.prototypes["WEAPON"], prototype_parents=self.prototypes)[0]
|
sting = spawner.spawn(self.prototypes["WEAPON"], prototype_parents=self.prototypes)[0]
|
||||||
self.assertEqual(sting.db.magic, False)
|
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'])
|
||||||
|
|
|
||||||
|
|
@ -141,10 +141,11 @@ class EvenniaTestMixin:
|
||||||
|
|
||||||
def restore_backups(self):
|
def restore_backups(self):
|
||||||
flush_cache()
|
flush_cache()
|
||||||
SESSIONS.data_out = self.backups[0]
|
if hasattr(self, "backups"):
|
||||||
SESSIONS.disconnect = self.backups[1]
|
SESSIONS.data_out = self.backups[0]
|
||||||
settings.DEFAULT_HOME = self.backups[2]
|
SESSIONS.disconnect = self.backups[1]
|
||||||
settings.PROTOTYPE_MODULES = self.backups[3]
|
settings.DEFAULT_HOME = self.backups[2]
|
||||||
|
settings.PROTOTYPE_MODULES = self.backups[3]
|
||||||
|
|
||||||
def mock_sessions(self):
|
def mock_sessions(self):
|
||||||
SESSIONS.data_out = Mock()
|
SESSIONS.data_out = Mock()
|
||||||
|
|
@ -167,8 +168,10 @@ class EvenniaTestMixin:
|
||||||
self.account.permissions.add("Developer")
|
self.account.permissions.add("Developer")
|
||||||
|
|
||||||
def teardown_accounts(self):
|
def teardown_accounts(self):
|
||||||
self.account.delete()
|
if hasattr(self, "account"):
|
||||||
self.account2.delete()
|
self.account.delete()
|
||||||
|
if hasattr(self, "account2"):
|
||||||
|
self.account2.delete()
|
||||||
|
|
||||||
def create_rooms(self):
|
def create_rooms(self):
|
||||||
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
|
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
|
||||||
|
|
@ -218,7 +221,8 @@ class EvenniaTestMixin:
|
||||||
self.session = session
|
self.session = session
|
||||||
|
|
||||||
def teardown_session(self):
|
def teardown_session(self):
|
||||||
del SESSIONS[self.session.sessid]
|
if hasattr(self, "sessions"):
|
||||||
|
del SESSIONS[self.session.sessid]
|
||||||
|
|
||||||
@patch("evennia.scripts.taskhandler.deferLater", _mock_deferlater)
|
@patch("evennia.scripts.taskhandler.deferLater", _mock_deferlater)
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue