-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_no_set.py
executable file
·64 lines (51 loc) · 2.96 KB
/
test_no_set.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
import unittest
from no_set import is_set, SetGame, get_other, exists_partition
class SetGameTest(unittest.TestCase):
def test_is_set(self):
self.assertTrue(is_set(("squiggle", "purple", "empty", "one"),
("squiggle", "purple", "empty", "two"),
("squiggle", "purple", "empty", "three")))
self.assertTrue(is_set(("squiggle", "purple", "empty", "one"),
("squiggle", "purple", "solid", "one"),
("squiggle", "purple", "lined", "one")))
self.assertTrue(is_set(("squiggle", "purple", "empty", "one"),
("squiggle", "green", "empty", "one"),
("squiggle", "red", "empty", "one")))
self.assertTrue(is_set(("squiggle", "purple", "empty", "one"),
("pill", "green", "solid", "two"),
("diamond", "red", "lined", "three")))
self.assertFalse(is_set(("squiggle", "purple", "empty", "one"),
("squiggle", "green", "solid", "two"),
("diamond", "red", "lined", "three")))
self.assertFalse(is_set(("squiggle", "purple", "empty", "one"),
("squiggle", "purple", "empty", "two"),
("squiggle", "purple", "empty", "one")))
def test_get_other(self):
self.assertEqual(get_other(("squiggle", "purple", "empty", "one"),
("squiggle", "green", "empty", "one")),
("squiggle", "red", "empty", "one"))
def test_exists_partition(self):
"""docstring for test_exists_partition"""
self.assertTrue(exists_partition((("squiggle", "purple", "empty", "one"),
("pill", "purple", "empty", "one"),
("diamond", "purple", "empty", "one"))))
self.assertTrue(exists_partition((("squiggle", "purple", "empty", "one"),
("squiggle", "purple", "empty", "two"),
("squiggle", "purple", "empty", "three"),
("pill", "purple", "empty", "one"),
("pill", "purple", "empty", "two"),
("pill", "purple", "empty", "three"))))
class WithoutReplacementTest(unittest.TestCase):
def setUp(self):
"""docstring for setUp"""
self.game = SetGame(with_replacement=False)
def test_exhaust_cards(self):
"""docstring for test_exhaust_cards"""
all_cards = set()
for i in xrange(81):
all_cards.add(self.game.get_random_card())
self.assertRaises(Exception, self.game.get_random_card)
self.assertEqual(81, len(all_cards))
if __name__ == '__main__':
unittest.main()