forked from rahulbot/Programming-Style-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-driven.py
32 lines (24 loc) · 860 Bytes
/
test-driven.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
# Verify that we can open and read the election results CSV correctly
# Showing a "test-driven" style
from electiondata import ElectionResults
import unittest
class ElectionResultsTest(unittest.TestCase):
def setUp(self):
self.results = ElectionResults('election_results_test_file.csv')
def testLoad(self):
self.results.load()
assert self.results!=None
assert self.results.file!=None
def testStateCount(self):
self.results.load()
state_count = self.results.state_count()
assert state_count==2
def testStates(self):
self.results.load()
names = self.results.states()
assert len(names)==2
assert names[0]=='Alaska'
assert names[1]=='Alabama'
# if this file is run directly, run the tests
if __name__ == "__main__":
unittest.main()