Coverage for app/pycardgame/tests/presets/uno/test_deck.py: 100.0%
28 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-07 20:57 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-04-07 20:57 +0000
1# PyCardGame - A base library for creating card games in Python
2# Copyright (C) 2025 Popa-42
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <https://www.gnu.org/licenses/>.
17from copy import copy
19from ....src.base import GenericCard
20from ....src.presets import (
21 DrawTwoCard,
22 NumberCard,
23 ReverseCard,
24 SkipCard,
25 UnoCard,
26 UnoDeck,
27 WildCard,
28 WildDrawFourCard,
29)
32def test_uno_deck_init():
33 deck = UnoDeck()
35 assert len(deck.cards) == 108
36 assert all(isinstance(card, GenericCard) for card in deck.cards)
37 assert all(isinstance(card, UnoCard) for card in deck.cards)
39 assert all(isinstance(card, NumberCard) for card in deck.cards[0:76])
40 assert all(isinstance(card, DrawTwoCard) for card in deck.cards[76:84])
41 assert all(isinstance(card, SkipCard) for card in deck.cards[84:92])
42 assert all(isinstance(card, ReverseCard) for card in deck.cards[92:100])
43 assert all(isinstance(card, WildCard) for card in deck.cards[100:104])
44 assert all(
45 isinstance(card, WildDrawFourCard) for card in deck.cards[104:108])
48def test_uno_deck_shuffle():
49 deck = UnoDeck()
50 original_order = copy(deck.cards)
51 deck.shuffle()
52 assert deck.cards != original_order
53 assert len(deck.cards) == 108
54 assert all(isinstance(card, UnoCard) for card in deck.cards)
57def test_uno_deck_str():
58 deck = UnoDeck()
59 assert str(deck) == f"UNO Deck with {len(deck.cards)} cards."
60 assert repr(deck) == f"UnoDeck(cards={deck.cards!r})"
63def test_uno_deck_repr():
64 deck = UnoDeck()
65 assert repr(deck) == f"UnoDeck(cards={deck.cards!r})"