def test_can_create_from_iterable_with_chars(self): pig = actor.Creature(name="Bobby", species="pig") unnamed_goblin = actor.Creature(species="goblin") trader = actor.Trader(name="Sidorovich") group = actor.Group(title="NPCs", characters=( pig, unnamed_goblin, trader, )) assert group.title == "NPCs" assert len(list(group.characters)) == 3 assert pig in group.characters assert unnamed_goblin in group.characters assert trader in group.characters assert str(group) == "NPCs"
def test_can_create_with_just_species(self): unnamed_goblin = actor.Creature(species="goblin") assert unnamed_goblin.name == "" assert unnamed_goblin.species == "goblin" assert str(unnamed_goblin) == unnamed_goblin.species
def test_can_not_create_without_name(self): with pytest.raises(TypeError): pig = actor.Creature()
def test_can_create_with_all_parameters(self): pig = actor.Creature(name="Bobby", species="pig") assert pig.name == "Bobby" assert pig.species == "pig" assert str(pig) == pig.name
def test_can_not_create_from_iterable_with_non_chars(self): pig = actor.Creature(name="Bobby", species="pig") with pytest.raises(TypeError): group = actor.Group( title="NPCs", characters=(pig, "this aint no character, this is a string"))