Exemple #1
0
def test_player_steal_money() -> None:
    """
    Tests stealing from player
    """
    p = Player("Bob", 5000)
    stolen = p.steal_money()
    assert p.money < 5000
    assert isinstance(stolen, str)
    p.money = 0
    stolen = p.steal_money()
    assert stolen == "A thief tried to steal from you, but you are flat broke!"
Exemple #2
0
def test_set_weapon() -> None:
    """
    :return:
    """
    bob = Player("Bob", 5000)
    gun = Gun()
    bob.weapon = gun
    assert bob.weapon == Gun()
    assert bob.money == 4500
    with raises(RuntimeError):
        bob.weapon = Blackmail()
    bob.money = 1_000_000
    bob.weapon = Blackmail()
    assert bob.weapon == Blackmail()