Skip to content

Commit

Permalink
Increase code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Roberts committed Jun 20, 2016
1 parent b0eb4b4 commit 79934f8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,28 @@ def test_get_name(self):
self.assertAlmostEqual(counts['Test4'] / rounds, 0.166, delta=0.05)
self.assertEqual(counts['Test5'] / rounds, 0)

def test_get_fullname(self):
counts = defaultdict(int)
rounds = 5000.0
name_files = {
'first:male': full_path('test/male.txt'),
'first:female': full_path('test/female.txt'),
'last': full_path('test/last.txt'),
}
with patch_file(name_files, self.names):
for i in range(int(rounds)):
counts[self.names.get_full_name()] += 1
self.assertAlmostEqual(counts['Male Last'] / rounds, 0.500, delta=0.05)
self.assertAlmostEqual(counts['Female Last'] / rounds, 0.500, delta=0.05)

def test_random_gender(self):
counts = defaultdict(int)
rounds = 5000.0
with patch_file(test_files, self.names):
for i in range(int(rounds)):
self.names.get_first_name()
counts[self.names.get_first_name()] += 1

self.assertAlmostEqual(counts['Male'] / rounds, 0.500, delta=0.05)
self.assertAlmostEqual(counts['Female'] / rounds, 0.500, delta=0.05)

Expand Down

0 comments on commit 79934f8

Please sign in to comment.