Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed unit tests to support new FILES layout.
Robert Vally committed Sep 29, 2014
commit 632141f0bff4cf743ccb61a6f0a66b19bce33e0d
16 changes: 8 additions & 8 deletions test_names.py
Original file line number Diff line number Diff line change
@@ -41,9 +41,9 @@ def __exit__(self, type, value, traceback):
names.FILES = self.old_files

test_files = {
'first:male': full_path('test/male.txt'),
'first:female': full_path('test/female.txt'),
'last': full_path('test/last.txt'),
'first:male': {'path': full_path('test/male.txt')},
'first:female': {'path': full_path('test/female.txt')},
'last': {'path': full_path('test/last.txt')}
}


@@ -52,7 +52,7 @@ class NamesTest(unittest.TestCase):
def test_get_name(self):
counts = defaultdict(int)
rounds = 5000.0
test_file = full_path('test/file1.txt')
test_file = {'path': full_path('test/file1.txt')}
for i in range(1, int(rounds)):
counts[names.get_name(test_file)] += 1
self.assertAlmostEqual(counts['Test1'] / rounds, 0.333, delta=0.05)
@@ -79,15 +79,15 @@ def test_correct_files(self):

def test_empty_file(self):
empty_files = {
'first:male': full_path('test/empty.txt'),
'first:female': full_path('test/empty.txt'),
'last': full_path('test/empty.txt'),
'first:male': {'path': full_path('test/empty.txt')},
'first:female': {'path': full_path('test/empty.txt')},
'last': {'path': full_path('test/empty.txt')},
}
with patch_file(empty_files):
self.assertEqual(names.get_first_name(gender='male'), "")
self.assertEqual(names.get_first_name(gender='female'), "")
self.assertEqual(names.get_last_name(), "")

def test_only_male_and_female_gender_are_supported(self):
with self.assertRaises(ValueError):
names.get_first_name(gender='other')