Ejemplo n.º 1
0
def test_score_one_player():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((1, 2))
    j1.ajouter_score_manche((3, 4))

    p = Partie([j1])

    assert p.who_win() == "Patrick"
Ejemplo n.º 2
0
def test_chain_strike_2():
    j1 = Joueur("TOTO")
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((2, 0))
    assert j1.calculer_score() == 66
Ejemplo n.º 3
0
def test_print_one_player():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((1, 2))
    j1.ajouter_score_manche((3, 4))

    p = Partie([j1])

    capturedOutput = io.StringIO()  # Create StringIO object
    sys.stdout = capturedOutput  #  and redirect stdout.
    p.print_score()  # Call unchanged function.
    sys.stdout = sys.__stdout__  # Reset redirect.

    assert capturedOutput.getvalue() == "Patrick 10\n"
Ejemplo n.º 4
0
def test_score():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((1, 2))
    j1.ajouter_score_manche((3, 4))

    j2 = Joueur("Bob")
    j2.ajouter_score_manche((1, 2))
    j2.ajouter_score_manche((5, 4))

    p = Partie([j1, j2])

    assert p.who_win() == "Bob"
Ejemplo n.º 5
0
def test_ajout_score_error2():
    with pytest.raises(TypeError):
        j1 = Joueur("Patrick")
        j1.changer_tableau_score([(10, 0), (10, 0), (10, 0), (10, 0), (10, 0),
                                  (10, 0), (10, 0), (10, 0), (10, 0), (10, 0),
                                  (10, 0)])
        j1.ajouter_score_manche((5, 5))
Ejemplo n.º 6
0
def test_ajout_Joueur_score_grand2():
    with pytest.raises(TypeError):
        j1 = Joueur("Kevin", [(1, 1), (4, 3), (1, 1), (4, 3), (1, 1), (4, 3),
                              (1, 1), (4, 3), (10, 0), (10, 0), (4, 0), (4, 0),
                              (4, 0)])
Ejemplo n.º 7
0
def test_ajout_tuple_hors_limite():
    with pytest.raises(TypeError):
        j1 = Joueur("Bertrand", [(1, 1), (1, 1), (1, 1), (1, 1), (1, 1),
                                 (1, 1), (1, 1), (1, 1), (1, 1), (1, 0)])
        j1.ajouter_score_manche((2, 3))
Ejemplo n.º 8
0
def test_ajout_tuple_negatif():
    with pytest.raises(TypeError):
        j1 = Joueur("Titeuf")
        j1.ajouter_score_manche((1, -2))
Ejemplo n.º 9
0
def test_limite_dix():
    j1 = Joueur("Eric", [(10, 0)])
    assert j1.calculer_score() == 10
Ejemplo n.º 10
0
def test_spare_coup():
    j1 = Joueur("Eric")
    j1.changer_tableau_score([(10, 0), (10, 0), (10, 0), (10, 0), (10, 0),
                              (10, 0), (10, 0), (10, 0), (10, 0), (10, 0),
                              (5, 5)])
    assert j1.calculer_score() == 285
Ejemplo n.º 11
0
def test_full_strike():
    j1 = Joueur("Patrick")
    j1.changer_tableau_score([(10, 0), (10, 0), (10, 0), (10, 0), (10, 0),
                              (10, 0), (10, 0), (10, 0), (10, 0), (10, 0),
                              (10, 0), (10, 0)])
    assert j1.calculer_score() == 300
Ejemplo n.º 12
0
def test_ajout_Joueur_score_negatif():
    with pytest.raises(TypeError):
        j1 = Joueur("Kevin", [(1, -1), (4, 3)])
Ejemplo n.º 13
0
def test_add_player():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((1, 2))
    j1.ajouter_score_manche((3, 4))
    j1.ajouter_score_manche((3, 4))
    j1.ajouter_score_manche((3, 4))
    j1.ajouter_score_manche((3, 4))
    j1.ajouter_score_manche((3, 4))

    j2 = Joueur("Bob")
    j2.ajouter_score_manche((1, 2))
    j2.ajouter_score_manche((5, 4))
    j2.ajouter_score_manche((5, 4))
    j2.ajouter_score_manche((5, 4))
    j2.ajouter_score_manche((5, 4))
    j2.ajouter_score_manche((5, 4))

    p = Partie()
    p.add_player(j1)
    p.add_player(j2)

    assert p.who_win() == "Bob"
Ejemplo n.º 14
0
def test_chain_strike():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((5, 2))
    assert j1.calculer_score() == 139
Ejemplo n.º 15
0
def test_strike():
    j1 = Joueur()
    j1.ajouter_score_manche((10, 0))
    j1.ajouter_score_manche((5, 2))
    assert j1.calculer_score() == 24
Ejemplo n.º 16
0
def test_spare():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((5, 5))
    j1.ajouter_score_manche((5, 2))
    assert j1.calculer_score() == 22
Ejemplo n.º 17
0
def test_limite_zero():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((1, 0))
    assert j1.calculer_score() == 1
Ejemplo n.º 18
0
def test_tuple():
    j1 = Joueur("Patrick")
    j1.ajouter_score_manche((1, 2))
    j1.ajouter_score_manche((3, 4))
    assert j1.calculer_score() == 10
Ejemplo n.º 19
0
def test_changer_score_negatif():
    with pytest.raises(TypeError):
        j1 = Joueur("Kevin")
        j1.changer_tableau_score([(1, 1), (-2, 3), (4, 4)])