mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
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)
|
||||
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])
|
||||
|
||||
|
|
|
|||
|
|
@ -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'])
|
||||
|
|
|
|||
|
|
@ -141,10 +141,11 @@ class EvenniaTestMixin:
|
|||
|
||||
def restore_backups(self):
|
||||
flush_cache()
|
||||
SESSIONS.data_out = self.backups[0]
|
||||
SESSIONS.disconnect = self.backups[1]
|
||||
settings.DEFAULT_HOME = self.backups[2]
|
||||
settings.PROTOTYPE_MODULES = self.backups[3]
|
||||
if hasattr(self, "backups"):
|
||||
SESSIONS.data_out = self.backups[0]
|
||||
SESSIONS.disconnect = self.backups[1]
|
||||
settings.DEFAULT_HOME = self.backups[2]
|
||||
settings.PROTOTYPE_MODULES = self.backups[3]
|
||||
|
||||
def mock_sessions(self):
|
||||
SESSIONS.data_out = Mock()
|
||||
|
|
@ -167,8 +168,10 @@ class EvenniaTestMixin:
|
|||
self.account.permissions.add("Developer")
|
||||
|
||||
def teardown_accounts(self):
|
||||
self.account.delete()
|
||||
self.account2.delete()
|
||||
if hasattr(self, "account"):
|
||||
self.account.delete()
|
||||
if hasattr(self, "account2"):
|
||||
self.account2.delete()
|
||||
|
||||
def create_rooms(self):
|
||||
self.room1 = create.create_object(self.room_typeclass, key="Room", nohome=True)
|
||||
|
|
@ -218,7 +221,8 @@ class EvenniaTestMixin:
|
|||
self.session = session
|
||||
|
||||
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)
|
||||
def setUp(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue