예제 #1
0
def other_character():
    """Create another Character instance for all tests to share."""
    _character = Character(savable=False)
    _character.active = True
    _character.name = "Target"
    _character.session = _other_session
    return _character
예제 #2
0
 def test_character_act(self, character, other_character):
     """Test that we can generate 'act' messages for a character."""
     assert not character.session._output
     assert not other_character.session._output
     # Generate messages for neither the source nor the target.
     character.act("a tree falls and nobody is around.", and_self=False)
     assert not character.session._output
     assert not other_character.session._output
     # Generate messages for the source but not the target.
     character.act("{s} dance{ss} {x} jigs.", context={"x": "five"})
     assert character.session._output
     assert character.session._output.pop() == "You dance five jigs.\n"
     assert not other_character.session._output
     # Generate messages for the target but not the source.
     character.act("{s} explode{ss}, hard.",
                   target=other_character,
                   and_self=False)
     assert not character.session._output
     assert other_character.session._output
     assert (other_character.session._output.pop() ==
             "Testing explodes, hard.\n")
     # Generate messages for the source and the target.
     character.act("{s} hit{ss} {t} in the face!", target=other_character)
     assert (
         character.session._output.pop() == "You hit Target in the face!\n")
     assert (other_character.session._output.pop() ==
             "Testing hits you in the face!\n")
     character.act("{s} speak{ss} gibberish for a moment.",
                   to=Character.all())
     assert (character.session._output.pop() ==
             "You speak gibberish for a moment.\n")
     assert (other_character.session._output.pop() ==
             "Testing speaks gibberish for a moment.\n")
     character.act("{s} does something to {t}.",
                   target=other_character,
                   to=Character.all(),
                   and_self=False)
     assert not character.session._output
     assert (other_character.session._output.pop() ==
             "Testing does something to you.\n")
예제 #3
0
 def test_room_chars(self):
     """Test that a room's character list functions properly."""
     assert not self.room.chars
     char = Character()
     char.resume(quiet=True)
     char.room = self.room
     assert set(self.room.chars) == {char}
     del Character._caches[char.get_key_name()][char.key]
     del char
     gc.collect()
     assert not self.room.chars
예제 #4
0
 def test_character_create(self):
     """Test that we can create a new character instance."""
     assert Character()
예제 #5
0
def character():
    """Create a Character instance for all tests to share."""
    return Character(savable=False)