generated from mwc/lab_weather
For function 3, it was similar to function 2 but we wanted the count so used the len command from function 1.
This commit is contained in:
@@ -41,7 +41,10 @@ def count_favorite_colors(people, name):
|
||||
>>> count_favorite_colors(family, "Raphael Chambers")
|
||||
1
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
for person in people:
|
||||
if person["name"] == name:
|
||||
return len(person["favorite_colors"])
|
||||
return None
|
||||
|
||||
def people_who_like_color(people, color):
|
||||
"""Returns a list containing only those people who like the given color.
|
||||
|
||||
@@ -17,10 +17,10 @@ from friend_functions import (
|
||||
get_color_dict,
|
||||
)
|
||||
|
||||
class TestCountPeople(TestCase):
|
||||
def test_returns_correct_value(self):
|
||||
self.assertEqual(count_people(family), 5)
|
||||
self.assertEqual(count_people(friends), 10)
|
||||
# class TestCountPeople(TestCase):
|
||||
# def test_returns_correct_value(self):
|
||||
# self.assertEqual(count_people(family), 5)
|
||||
# self.assertEqual(count_people(friends), 10)
|
||||
|
||||
# class TestGetEmail(TestCase):
|
||||
# def test_returns_email_when_person_found(self):
|
||||
@@ -30,14 +30,14 @@ class TestCountPeople(TestCase):
|
||||
# def test_returns_none_when_person_missing(self):
|
||||
# self.assertEqual(get_email(family, "Ken Kesey"), None)
|
||||
|
||||
# class TestCountFavoriteColors(TestCase):
|
||||
# def test_returns_len_favorite_colors_when_person_found(self):
|
||||
# self.assertEqual(count_favorite_colors(family, "Tad Winters"), 2)
|
||||
# self.assertEqual(count_favorite_colors(friends,"Connor Rodriguez"), 4)
|
||||
# self.assertEqual(count_favorite_colors(friends, "Yuli Reynolds"), 0)
|
||||
class TestCountFavoriteColors(TestCase):
|
||||
def test_returns_len_favorite_colors_when_person_found(self):
|
||||
self.assertEqual(count_favorite_colors(family, "Tad Winters"), 2)
|
||||
self.assertEqual(count_favorite_colors(friends,"Connor Rodriguez"), 4)
|
||||
self.assertEqual(count_favorite_colors(friends, "Yuli Reynolds"), 0)
|
||||
|
||||
# def test_returns_none_when_person_missing(self):
|
||||
# self.assertEqual(count_favorite_colors(family, "Ken Kesey"), None)
|
||||
def test_returns_none_when_person_missing(self):
|
||||
self.assertEqual(count_favorite_colors(family, "Ken Kesey"), None)
|
||||
|
||||
# class TestPeopleWhoLikeColor(TestCase):
|
||||
# def test_returns_correct_length(self):
|
||||
|
||||
Reference in New Issue
Block a user