minor cleanup

This commit is contained in:
Cal 2024-09-06 15:35:50 -06:00
parent d7d6b311ec
commit fdfb2019cf
2 changed files with 2 additions and 8 deletions

View file

@ -479,12 +479,7 @@ class ObjectDBManager(TypedObjectManager):
# deal with result
if match_number is not None:
# this indicates someone attempting to get a single match with a match-number
if match_number >= len(matches):
# the search attempted to target a higher match index than exists in the candidates.
# This leads to a no-match.
matches = self.none()
elif 0 <= match_number < len(matches):
if 0 <= match_number < len(matches):
# limit to one match (we still want a queryset back)
# NOTE: still haven't found a way to avoid a second lookup
matches = self.filter(id=matches[match_number].id)

View file

@ -250,11 +250,10 @@ class TestObjectManager(BaseEvenniaTest):
def test_get_objs_with_key_or_alias(self):
query = ObjectDB.objects.get_objs_with_key_or_alias("Char")
self.assertEqual(list(query), [self.char1])
self.assertEqual(list(query), [self.char1])
query = ObjectDB.objects.get_objs_with_key_or_alias(
"Char", typeclasses="evennia.objects.objects.DefaultObject"
)
self.assertFalse(query)
self.assertEqual(list(query), [])
query = ObjectDB.objects.get_objs_with_key_or_alias(
"Char", candidates=[self.char1, self.char2]
)