def test_tah_o():
    """
    Pozitivní testy se symbolem "o".
    """
    assert tah("--------------------", 0, "o") == "o-------------------"
    assert tah("--------------------", 10, "o") == "----------o---------"
    assert tah("--------------------", 19, "o") == "-------------------o"
def test_tah_x():
    """
    Pozitivní testy se symbolem "x".
    """
    assert tah("--------------------", 0, "x") == "x-------------------"
    assert tah("--------------------", 10, "x") == "----------x---------"
    assert tah("--------------------", 19, "x") == "-------------------x"
Exemplo n.º 3
0
def test_tah():
    pole = piskvorky.nove_pole(20)
    assert pole == '--------------------'
    assert piskvorky.tah(pole, 0, 'x') == 'x-------------------'
    assert piskvorky.tah(pole, 1, 'o') == '-o------------------'
    assert piskvorky.tah(pole, 19, 'x') == '-------------------x'
    assert piskvorky.tah(pole, 18, 'x') == '------------------x-'
Exemplo n.º 4
0
def test_tah_exception():

    with pytest.raises(PiskvorkyException.PiskvorkyException):
        piskvorky.tah('oxoxoxoxoxoxoxoxoxox', 0, 'x')

    with pytest.raises(PiskvorkyException.PiskvorkyException):
        piskvorky.tah('', 0, 'x')

    with pytest.raises(ValueError):
        piskvorky.tah('-', 1, 'x')

    with pytest.raises(ValueError):
        piskvorky.tah('---------------', 20, 'x')

    with pytest.raises(ValueError):
        piskvorky.tah('-----------------', -1, 'x')
Exemplo n.º 5
0
def tah_pocitace(herni_pole):
    while True:
        pozice = random.randrange(0, 19)
        print("počítač si vybírá pozici", pozice)
        if herni_pole[pozice] != "-":
            print("Políčko číslo ", pozice, "je obsazené, zkus jiné")
        else:
            return piskvorky.tah(herni_pole, "o", pozice)
Exemplo n.º 6
0
def test_tah_mimo_pole():
    try:
        assert tah(10 * '-', 10, 'x')
    except ValueError:
        assert True


# def test_tah_hrace_input_str():
#     assert tvuj_tah == 'avc'
Exemplo n.º 7
0
def tah_pocitace(pole):
    """
    Vrátí herní pole se zaznamenaným tahem počítače
    """
    #print('Počítač je na řadě:')
    symbol_pocitace = 'o'
    while True:
        cislo_policka = randrange(0,DELKA_POLE)
        if pole[cislo_policka] == '-':
            return piskvorky.tah(pole, cislo_policka, symbol_pocitace)
def tah_pocitace(pole):
    pc_cislo_pole = randrange(len(pole))
    while not "-" in pole[pc_cislo_pole]:
        pc_cislo_pole = randrange(len(pole))
    return tah(pole, pc_cislo_pole, "o")
Exemplo n.º 9
0
def test_tah_33_nejde():
    with pytest.raises(ValueError):
        pole = tah(prazdne_pole(), 'x', 33)
Exemplo n.º 10
0
def test_tah_do_plneho():
    pole = 'xoxoxoxo-oxoxoxoxoxo'
    pole = tah(pole, 'x', 8)
    assert pole == 'xo' * 10
Exemplo n.º 11
0
def test_tah_o2_je_treti_o():
    pole = tah(prazdne_pole(), 'o', 2)
    assert pole == '--o' + ('-' * 17)
Exemplo n.º 12
0
def test_tah_x0_je_prvni_x():
    pole = tah(prazdne_pole(), 'x', 0)
    assert pole == 'x' + ('-' * 19)
Exemplo n.º 13
0
def test_hrat_teckama_nejde():
    with pytest.raises(ValueError):
        pole = tah(prazdne_pole(), '.', 2)
Exemplo n.º 14
0
def test_tah_x_na_pozici():
    pole = '-----'
    pozice = 2
    symbol = 'x'
    assert tah(pole, pozice, symbol) == '--x--'
Exemplo n.º 15
0
def test_tah():
    assert piskvorky.tah('-------', 'x', 5) == '-----x-'
    assert piskvorky.tah('-------', 'x', 0) == 'x------'
Exemplo n.º 16
0
def test_spravny_tah():
    assert tah(pole, 3, "x") == "---x-"
Exemplo n.º 17
0
def test_tah():
    assert piskvorky.tah('-------', 'x', 5) == '-----x-'
    assert piskvorky.tah('-------', 'x', 0) == 'x------'
Exemplo n.º 18
0
def test_tah():
    assert p.tah("-----", 1, "x") == "-x---"
    assert p.tah("-----", 0, "x") == "x----"
Exemplo n.º 19
0
def test_spatny_tah():
    with pytest.raises(TypeError):
        tah(pole, "str", "x")
Exemplo n.º 20
0
def test_tah():
    pole = piskvorky.tah('--------------------', 1, "x")
    assert len(pole) == 20
Exemplo n.º 21
0
def test_tah():
    assert tah(10 * '-', 7, 'x') == '-------x--'
    assert tah(10 * '-', 0, 'x') == 'x---------'
    assert tah(10 * '-', 9, 'x') == '---------x'
    assert tah(10 * '-', 0, 'str') == 'str---------'