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"
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-'
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')
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)
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'
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")
def test_tah_33_nejde(): with pytest.raises(ValueError): pole = tah(prazdne_pole(), 'x', 33)
def test_tah_do_plneho(): pole = 'xoxoxoxo-oxoxoxoxoxo' pole = tah(pole, 'x', 8) assert pole == 'xo' * 10
def test_tah_o2_je_treti_o(): pole = tah(prazdne_pole(), 'o', 2) assert pole == '--o' + ('-' * 17)
def test_tah_x0_je_prvni_x(): pole = tah(prazdne_pole(), 'x', 0) assert pole == 'x' + ('-' * 19)
def test_hrat_teckama_nejde(): with pytest.raises(ValueError): pole = tah(prazdne_pole(), '.', 2)
def test_tah_x_na_pozici(): pole = '-----' pozice = 2 symbol = 'x' assert tah(pole, pozice, symbol) == '--x--'
def test_tah(): assert piskvorky.tah('-------', 'x', 5) == '-----x-' assert piskvorky.tah('-------', 'x', 0) == 'x------'
def test_spravny_tah(): assert tah(pole, 3, "x") == "---x-"
def test_tah(): assert p.tah("-----", 1, "x") == "-x---" assert p.tah("-----", 0, "x") == "x----"
def test_spatny_tah(): with pytest.raises(TypeError): tah(pole, "str", "x")
def test_tah(): pole = piskvorky.tah('--------------------', 1, "x") assert len(pole) == 20
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---------'