예제 #1
0
def test_compare_scores():
    assert Hundred.compare_scores(
        100, 100) == "You are level with the Computer at 100"
    assert Hundred.compare_scores(0,
                                  0) == "You are level with the Computer at 0"
    assert Hundred.compare_scores(76, 25) == "You are 51 BEHIND the Computer"
    assert Hundred.compare_scores(43, 68) == "You are 25 AHEAD of the Computer"
예제 #2
0
def test_roll_seed_1():
    random.seed(1)  # will produce 2,5,1,...
    assert Hundred.roll() == 2
예제 #3
0
def test_is_game_over():
    assert Hundred.is_game_over(29, 50) is False
    assert Hundred.is_game_over(100, 100) is False
    assert Hundred.is_game_over(120, 120) is False
    assert Hundred.is_game_over(123, 99) is True
    assert Hundred.is_game_over(87, 100) is True
예제 #4
0
def test_ask_yes_or_no_NO():
    sys.stdin = open("human_inputs5.txt")  #read input from file. only 1 "N"
    assert Hundred.ask_yes_or_no("Roll dice again? 'Y' or 'N':") == False
def test_computer_move_inputs1randomseed3_15_15(
):  # Agressive play i.e 5 rolls
    random.seed(3)  # will produce 2,5,5,2,3,...
    assert Hundred.computer_move(15, 15) == 17
예제 #6
0
def test_roll_seed_5():
    random.seed(5)  # will produce 5,3,6,...
    assert Hundred.roll() == 5
예제 #7
0
def test_roll_seed_7():
    random.seed(7)  # will produce 3,2,4,.....
    assert Hundred.roll() == 3
def test_human_move_inputs1randomseed3_15_10():
    sys.stdin = open(
        "human_inputs2.txt")  #read input from file. 8 "Y" and 1 "N"
    random.seed(3)  # will produce 2,5,5,2,3,5,4,6,5,1...
    assert Hundred.human_move(15, 10) == 32
def test_human_move_inputs1randomseed3_5_20():
    sys.stdin = open(
        "human_inputs3.txt")  #read input from file. 11 "Y" and 1 "N"
    random.seed(3)  # will produce 2,5,5,2,3,5,4,6,5,1,5....
    assert Hundred.human_move(5, 20) == 0
def test_computer_move_inputs1randomseed7_0_0():  # Agressive play i.e 5 rolls
    random.seed(7)  # will produce 3,2,4,6,1,.....
    assert Hundred.computer_move(0, 0) == 0
def test_computer_move_inputs1randomseed7_8_0():  # Gentle play i.e 2 rolls
    random.seed(7)  # will produce 3,2,4,6,1,.....
    assert Hundred.computer_move(8, 0) == 5
def test_computer_move_inputs1randomseed6_60_31():  # Gentle play i.e 2 rolls
    random.seed(6)  # will produce 5,1,4,3,1,....
    assert Hundred.computer_move(60, 31) == 0
def test_computer_move_inputs1randomseed5_15_10():  # Gentle play i.e 2 rolls
    random.seed(5)  # will produce 5,3,6,3,6,...
    assert Hundred.computer_move(15, 10) == 8
def test_computer_move_inputs1randomseed3_45_20():  # Gentle play i.e 2 rolls
    random.seed(3)  # will produce 2,5,5,2,3,....
    assert Hundred.computer_move(45, 20) == 7
예제 #15
0
def test_roll_seed_2():
    random.seed(2)  # will produce 1,1,1,...
    assert Hundred.roll() == 1
def test_human_move_inputs1randomseed5_15_10():
    sys.stdin = open(
        "human_inputs1.txt")  #read input from file. 3 "Y" and 1 "N"
    random.seed(5)  # will produce 5,3,6,3,6,6,6,5,1,...
    assert Hundred.human_move(15, 10) == 14
예제 #17
0
def test_roll_seed_3():
    random.seed(3)  # will produce 2,5,5,....
    assert Hundred.roll() == 2
def test_human_move_inputs1randomseed3_60_31():
    sys.stdin = open(
        "human_inputs4.txt")  #read input from file. 5 "Y" and 1 "N"
    random.seed(3)  # will produce 2,5,5,2,3,5,4,6,5,1,5....
    assert Hundred.human_move(60, 31) == 17
예제 #19
0
def test_roll_seed_6():
    random.seed(6)  # will produce 5,1,4,....
    assert Hundred.roll() == 5
def test_human_move_inputs1randomseed5_0_0():
    sys.stdin = open(
        "human_inputs4.txt")  #read input from file. 5 "Y" and 1 "N"
    random.seed(5)  # will produce 5,3,6,3,6,6,6,5,1,4,2.....
    assert Hundred.human_move(0, 0) == 23
예제 #21
0
def test_roll_seed_():
    random.seed(9)  # will produce 4,5,3,.....
    assert Hundred.roll() == 4
def test_human_move_inputs1randomseed5_23_23():
    sys.stdin = open("human_inputs5.txt")  #read input from file. only 1 "N"
    random.seed(5)  # will produce 5,3,6,3,6,6,6,5,1,4,2.....
    assert Hundred.human_move(23, 23) == 0
예제 #23
0
def test_ask_yes_or_no_YES():
    sys.stdin = open("human_inputs6.txt")  #read input from file. only 1 "Y"
    assert Hundred.ask_yes_or_no("Roll dice again? 'Y' or 'N':") == True
def test_computer_move_inputs1randomseed1_15_20(
):  # Agressive play i.e 5 rolls
    random.seed(1)  # will produce 2,5,1,3,1,...
    assert Hundred.computer_move(15, 20) == 0