Hong-Phuc Bui
2025-05-16 c5537a297ea7a764e0815fdc5c585076add7f30c
auto-test
1 files modified
3 files added
1 files deleted
74 ■■■■ changed files
ub-3/.gitignore 5 ●●●●● patch | view | raw | blame | history
ub-3/anleitung.md 17 ●●●●● patch | view | raw | blame | history
ub-3/tictactoe.py 2 ●●● patch | view | raw | blame | history
ub-3/tictactoe.test.py 16 ●●●●● patch | view | raw | blame | history
ub-3/tictactoe_test.py 34 ●●●●● patch | view | raw | blame | history
ub-3/.gitignore
New file
@@ -0,0 +1,5 @@
__pycache__/
.pytest_cache/
.coverage
htmlcov/
ub-3/anleitung.md
New file
@@ -0,0 +1,17 @@
# 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
```
ub-3/tictactoe.py
@@ -101,7 +101,7 @@
                
if __name__ == "__main__":
print_tafel(tafel)
aktuelle_spieler = 1
ub-3/tictactoe.test.py
File was deleted
ub-3/tictactoe_test.py
New file
@@ -0,0 +1,34 @@
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