mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Fix Unexpected keyword argument 'prototype' error when spawning
This commit is contained in:
parent
3cd5be6e82
commit
1c99e89f1c
2 changed files with 41 additions and 2 deletions
|
|
@ -1045,6 +1045,45 @@ class TestIssue2908(BaseEvenniaTest):
|
|||
self.assertEqual(obj[0].location, self.room1)
|
||||
|
||||
|
||||
class TestIssue3824(BaseEvenniaTest):
|
||||
"""
|
||||
Test that $obj, $objlist, and $search callables work correctly when spawning prototypes.
|
||||
|
||||
"""
|
||||
|
||||
def test_spawn_with_search_callables(self):
|
||||
"""Test spawning prototype with $obj, $objlist, and $search callables."""
|
||||
# Setup: tag some objects for searching
|
||||
self.room1.tags.add("test_location", category="zone")
|
||||
self.room2.tags.add("test_location", category="zone")
|
||||
self.obj1.tags.add("test_item", category="item_type")
|
||||
|
||||
# Create prototype using all three search callables
|
||||
prot = {
|
||||
"prototype_key": "test_search_callables",
|
||||
"typeclass": "evennia.objects.objects.DefaultObject",
|
||||
"key": "test object",
|
||||
"attr_obj": f"$obj({self.obj1.dbref})",
|
||||
"attr_search": "$search(Char)",
|
||||
"attr_objlist": "$objlist(test_location, category=zone, type=tag)",
|
||||
}
|
||||
|
||||
# This should not raise TypeError about 'prototype' kwarg
|
||||
objs = spawner.spawn(prot, caller=self.char1)
|
||||
|
||||
self.assertEqual(len(objs), 1)
|
||||
obj = objs[0]
|
||||
|
||||
# Verify all search callables worked correctly
|
||||
self.assertEqual(obj.db.attr_obj, self.obj1)
|
||||
self.assertEqual(obj.db.attr_search, self.char1)
|
||||
# attr_objlist should be a list or list-like object with 2 rooms
|
||||
objlist = obj.db.attr_objlist
|
||||
self.assertEqual(len(objlist), 2)
|
||||
self.assertIn(self.room1, objlist)
|
||||
self.assertIn(self.room2, objlist)
|
||||
|
||||
|
||||
class TestIssue3101(EvenniaCommandTest):
|
||||
"""
|
||||
Spawning and using create_object should store the same `typeclass_path` if using
|
||||
|
|
|
|||
|
|
@ -1131,12 +1131,12 @@ def funcparser_callable_search(*args, caller=None, access="control", **kwargs):
|
|||
- "$search(beach, category=outdoors, type=tag)
|
||||
|
||||
"""
|
||||
# clean out funcparser-specific kwargs so we can use the kwargs for
|
||||
# clean out funcparser and protfunc_parser-specific kwargs so we can use the kwargs for
|
||||
# searching
|
||||
search_kwargs = {
|
||||
key: value
|
||||
for key, value in kwargs.items()
|
||||
if key not in ("funcparser", "raise_errors", "type", "return_list")
|
||||
if key not in ("funcparser", "raise_errors", "type", "return_list", "prototype")
|
||||
}
|
||||
return_list = str(kwargs.pop("return_list", "false")).lower() == "true"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue