1 files modified
3 files added
1 files deleted
New file |
| | |
| | | __pycache__/ |
| | | .pytest_cache/ |
| | | .coverage |
| | | htmlcov/ |
| | | |
New file |
| | |
| | | # automatisierter Test in Python |
| | | |
| | | |
| | | ## Python Package |
| | | |
| | | |
| | | ``` |
| | | pip install -U pytest |
| | | pip install -U pytest-cov |
| | | ``` |
| | | |
| | | |
| | | ## Test |
| | | |
| | | ``` |
| | | pytest --cov=tictactoe --cov-report html tictactoe_test.py |
| | | ``` |
| | |
| | | |
| | | |
| | | |
| | | |
| | | print_tafel(tafel) |
| | | aktuelle_spieler = 1 |
| | | |
| | | (spiel_ende, gewinner) = (False, 0) |
| | | |
| | | while not spiel_ende : |
| | | (spiel_ende, gewinner) = spiel_bewerten(tafel) |
| | | user_input(aktuelle_spieler, tafel) |
| | | if __name__ == "__main__": |
| | | print_tafel(tafel) |
| | | if aktuelle_spieler == 1: |
| | | aktuelle_spieler = 2 |
| | | else: |
| | | aktuelle_spieler = 1 |
| | | aktuelle_spieler = 1 |
| | | |
| | | print("Spiel beendet!") |
| | | (spiel_ende, gewinner) = (False, 0) |
| | | |
| | | while not spiel_ende : |
| | | (spiel_ende, gewinner) = spiel_bewerten(tafel) |
| | | user_input(aktuelle_spieler, tafel) |
| | | print_tafel(tafel) |
| | | if aktuelle_spieler == 1: |
| | | aktuelle_spieler = 2 |
| | | else: |
| | | aktuelle_spieler = 1 |
| | | |
| | | print("Spiel beendet!") |
| | | |
| | | |
| | | |
New file |
| | |
| | | from tictactoe import pruefe_combination, has_spieler_gewonnen, PL1, PL2, EMPTY |
| | | |
| | | |
| | | def test_pruefe_combination_horizontal(): |
| | | test_board = [ |
| | | [PL1, PL1, PL1], |
| | | [EMPTY, PL2, EMPTY], |
| | | [EMPTY, PL2, EMPTY] |
| | | ] |
| | | |
| | | result = pruefe_combination( (0,0,"hvd"), test_board ) |
| | | assert result |
| | | |
| | | |
| | | def test_pruefe_combination_vertikal(): |
| | | test_board = [ |
| | | [PL1, EMPTY, EMPTY], |
| | | [PL1, PL2, EMPTY], |
| | | [PL1, PL2, EMPTY] |
| | | ] |
| | | |
| | | result = pruefe_combination( (0,0,"hvd"), test_board ) |
| | | assert result |
| | | |
| | | |
| | | def test_pruefe_combination_diagonal(): |
| | | test_board = [ |
| | | [PL1, EMPTY, EMPTY], |
| | | [PL2, PL1, EMPTY], |
| | | [PL1, EMPTY, PL1] |
| | | ] |
| | | |
| | | result = pruefe_combination( (0,0,"hvd"), test_board ) |
| | | assert result |