Files
011-black-jack/tests/test_package.py
Tirsvad 3c99040b96 Add Blackjack game: rules, card rendering, game loop and tests
Implement the playable console game for gateway MIL-002.

- rules.py: deal_card, calculate_score (blackjack = 0, aces drop 11 ->
  1)
  and compare with an Outcome enum; no console I/O
- display.py: hand rendering as plain-text rank plus suit emoji (keycap
  emoji rendered as boxes in common terminals), score formatting and
  outcome messages
- art.py: course logo shown at the start of every game
- game.py: play_game (hit/stand, dealer draws below 17), play (restart
  loop, console clear, logo) and ask_yes_no with re-prompt; read, write
  and draw are injected so games can be scripted
- __main__.py: python -m blackjack entry point, exits cleanly on
  Ctrl+C/Ctrl+D
- constants.py: card ranks and suits, prompts and messages
- tests: 32 new unit and scripted end-to-end tests (35 in total)
- README: run instructions for python -m blackjack

Closes #7
Closes #8
Closes #9
Closes #10
Closes #11
Closes #12
Closes #13
Closes #14

Task: MIL-002#1
Task: MIL-002#2
Task: MIL-002#3
Task: MIL-002#4
Task: MIL-002#5
Task: MIL-002#6
Task: MIL-002#7
Task: MIL-002#8
2026-10-04 22:04:40 +08:00

39 lines
984 B
Python

"""!
@file test_package.py
@brief Smoke tests: the package imports and its constants match the house rules.
"""
import unittest
import blackjack
from blackjack import constants
class TestPackage(unittest.TestCase):
"""!
@brief Checks that the package and its constants load.
"""
def test_package_has_version(self) -> None:
"""!
@brief The package exposes a version string.
"""
self.assertTrue(blackjack.__version__)
def test_deck_matches_house_rules(self) -> None:
"""!
@brief The deck is the 13-card list from the assignment.
"""
self.assertEqual(constants.CARDS, [11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10])
def test_every_card_has_an_emoji_face(self) -> None:
"""!
@brief Every card in the deck has a rank to render.
"""
for card in constants.CARDS:
self.assertIn(card, constants.CARD_RANKS)
if __name__ == "__main__":
unittest.main()