-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_card.py
More file actions
41 lines (32 loc) · 1.25 KB
/
test_card.py
File metadata and controls
41 lines (32 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from unittest import TestCase
from card import Card
class TestCard(TestCase):
def test_card__unknown_int(self):
def one():
return Card(1, "Test")
self.assertRaises(AssertionError, one)
def test_card__unknown_symbol(self):
def symbol():
return Card("Sym", "Test")
self.assertRaises(AssertionError, symbol)
def test_value__integer_cards(self):
for value in range(2, 11):
with self.subTest(value=value):
card = Card(value, "Test")
self.assertEqual(value, card.value())
def test_value__string_cards(self):
for value in range(2, 11):
with self.subTest(value=value):
card = Card(str(value), "Test")
self.assertEqual(value, card.value())
def test_value__picture_cards(self):
for symbol in ["J", "Q", "K"]:
with self.subTest(value=symbol):
card = Card(symbol, "Test")
self.assertEqual(10, card.value())
def test_value__ace_high(self):
card = Card("A", "Test")
self.assertEqual(11, card.value(high=True))
def test_value__ace_low(self):
card = Card("A", "Test")
self.assertEqual(1, card.value(high=False))