コード例 #1
0
def test_team_attack_deaths():
    team_one = SuperHeroes.Team("One")
    jodie = SuperHeroes.Hero("Jodie Foster")
    aliens = SuperHeroes.Ability("Alien Friends", 10000)
    jodie.add_ability(aliens)
    team_one.add_hero(jodie)
    team_two = SuperHeroes.Team("Two")
    athena = SuperHeroes.Hero("Athena")
    socks = SuperHeroes.Armor("Socks", 10)
    athena.add_armor(socks)
    team_two.add_hero(athena)
    assert team_two.heroes[0].deaths == 0
    team_one.attack(team_two)
    assert team_two.heroes[0].deaths == 1
コード例 #2
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_team_remove_unlisted():
    # Test that if no results found return 0
    team = SuperHeroes.Team("One")
    jodie = SuperHeroes.Hero("Jodie Foster")
    team.add_hero(jodie)
    code = team.remove_hero("Athena")
    assert code == 0
コード例 #3
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_team_remove_hero():
    team = SuperHeroes.Team("One")
    jodie = SuperHeroes.Hero("Jodie Foster")
    team.add_hero(jodie)
    assert team.heroes[0].name == "Jodie Foster"
    team.remove_hero("Jodie Foster")
    assert len(team.heroes) == 0
コード例 #4
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_print_heroes():
    team = SuperHeroes.Team("One")
    jodie = SuperHeroes.Hero("Jodie Foster")
    team.add_hero(jodie)
    athena = SuperHeroes.Hero("Athena")
    team.add_hero(athena)
    output_string = capture_console_output(team.view_all_heroes)

    assert "Jodie Foster" in output_string
    assert "Athena" in output_string
コード例 #5
0
def create_team(heroes=[]):
    teams = [
        "Orchids", "Red", "Blue", "Cheese Steaks", "Warriors", "49ers",
        "Marvel", "DC", "Rat Pack", "The Little Red Riding Hoods", "Team One",
        "Generic Team", "X-men", "Team Two", "Golden Champions",
        "Vegan Protectors", "The Cardinals", "Winky Bears", "Steelsmiths",
        "Boilermakers", "Nincompoops"
    ]
    name = teams[random.randint(0, len(teams) - 1)]
    team = SuperHeroes.Team(name)
    if len(heroes) > 0:
        for member in heroes:
            team.add_hero(member)

    return team
コード例 #6
0
def test_revive_heroes():
    heroes = []
    for _ in range(0, 20):
        heroes.append(create_hero(health=60))

    team_one = SuperHeroes.Team("One")
    for hero in heroes:
        team_one.add_hero(hero)

    team_one.defend(300)
    for hero in team_one.heroes:
        assert hero.health == 45
    team_one.revive_heroes()
    for hero in team_one.heroes:
        assert hero.health == 60
コード例 #7
0
def test_team_defend():
    heroes = []
    for _ in range(0, 20):
        heroes.append(create_hero(health=20))
        print(heroes[_].health)
    team_one = SuperHeroes.Team("One")
    for hero in heroes:
        team_one.add_hero(hero)

    deaths = team_one.defend(100)
    for hero in team_one.heroes:
        assert hero.health == 15

    assert deaths == 0

    assert team_one.defend(400) == 20
コード例 #8
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_find_empty_hero():
    team = SuperHeroes.Team("One")
    assert team.find_hero("Alexa") == 0
コード例 #9
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_find_unlisted_hero():
    team = SuperHeroes.Team("One")
    jodie = SuperHeroes.Hero("Jodie Foster")
    team.add_hero(jodie)
    assert team.find_hero("Alexa") == 0
コード例 #10
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_find_hero():
    team = SuperHeroes.Team("One")
    jodie = SuperHeroes.Hero("Jodie Foster")
    team.add_hero(jodie)
    hero = team.find_hero("Jodie Foster")
    assert hero.name == "Jodie Foster"
コード例 #11
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_team_remove_empty_list():
    team = SuperHeroes.Team("One")
    assert team.remove_hero("Athena") == 0
コード例 #12
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_team_name():
    team = SuperHeroes.Team("One")
    assert team.name == "One"
コード例 #13
0
ファイル: hero_test.py プロジェクト: elgrian/SuperHeroes.py
def test_team_instance():
    team = SuperHeroes.Team("One")
    assert team