|
12 | 12 |
|
13 | 13 | from sets_categories_data import (VEGAN,
|
14 | 14 | VEGETARIAN,
|
15 |
| - KETO, PALEO, |
| 15 | + KETO, |
| 16 | + PALEO, |
16 | 17 | OMNIVORE,
|
17 | 18 | ALCOHOLS,
|
18 | 19 | SPECIAL_INGREDIENTS,
|
@@ -40,70 +41,63 @@ class SetsTest(unittest.TestCase):
|
40 | 41 |
|
41 | 42 | @pytest.mark.task(taskno=1)
|
42 | 43 | def test_clean_ingredients(self):
|
43 |
| - input_data = recipes_with_duplicates |
44 |
| - result_data = recipes_without_duplicates |
45 |
| - number_of_variants = range(1, len(input_data) + 1) |
| 44 | + test_data = zip(recipes_with_duplicates[::3], recipes_without_duplicates[::3]) |
46 | 45 |
|
47 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
48 |
| - with self.subTest(f"variation #{variant}", item=item, result=result): |
49 |
| - self.assertEqual(clean_ingredients(item[0], item[1]), (result[1], result[2])) |
| 46 | + for variant, (item, result) in enumerate(test_data, start=1): |
| 47 | + with self.subTest(f"variation #{variant}", item=item[0], result=result[1]): |
| 48 | + error_msg = f"Expected a cleaned ingredient list for {item[0]}, but the ingredients aren't cleaned as expected." |
| 49 | + self.assertEqual(clean_ingredients(item[0], item[1]), (result[1], result[2]), msg=error_msg) |
50 | 50 |
|
51 | 51 | @pytest.mark.task(taskno=2)
|
52 | 52 | def test_check_drinks(self):
|
53 |
| - input_data = all_drinks |
54 |
| - result_data = drink_names |
55 |
| - number_of_variants = range(1, len(input_data) + 1) |
| 53 | + test_data = zip(all_drinks[::2], drink_names[::2]) |
56 | 54 |
|
57 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
| 55 | + for variant, (item, result) in enumerate(test_data, start=1): |
58 | 56 | with self.subTest(f"variation #{variant}", item=item, result=result):
|
59 |
| - self.assertEqual(check_drinks(item[0], item[1]), (result)) |
| 57 | + error_msg = f"Expected {result} for {item}, but got something else instead." |
| 58 | + self.assertEqual(check_drinks(item[0], item[1]), (result), msg=error_msg) |
60 | 59 |
|
61 | 60 | @pytest.mark.task(taskno=3)
|
62 | 61 | def test_categorize_dish(self):
|
63 |
| - input_data = sorted(recipes_without_duplicates, reverse=True) |
64 |
| - result_data = dishes_categorized |
65 |
| - number_of_variants = range(1, len(input_data) + 1) |
| 62 | + test_data = zip(sorted(recipes_without_duplicates, reverse=True)[::3], dishes_categorized[::3]) |
66 | 63 |
|
67 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
| 64 | + for variant, (item, result) in enumerate(test_data, start=1): |
68 | 65 | with self.subTest(f"variation #{variant}", item=item, result=result):
|
69 |
| - self.assertEqual(categorize_dish(item[1], item[2]), (result)) |
| 66 | + error_message = f"Exptected category {result} for {item[0]}, but got a different category instead." |
| 67 | + self.assertEqual(categorize_dish(item[1], item[2]), (result), msg=error_message) |
70 | 68 |
|
71 | 69 | @pytest.mark.task(taskno=4)
|
72 | 70 | def test_tag_special_ingredients(self):
|
73 |
| - input_data = dishes_to_special_label |
74 |
| - result_data = dishes_labeled |
75 |
| - number_of_variants = range(1, len(input_data) + 1) |
| 71 | + test_data = zip(dishes_to_special_label[::3], dishes_labeled[::3]) |
76 | 72 |
|
77 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
| 73 | + for variant, (item, result) in enumerate(test_data, start=1): |
78 | 74 | with self.subTest(f"variation #{variant}", item=item, result=result):
|
79 |
| - self.assertEqual(tag_special_ingredients(item), (result)) |
| 75 | + error_message = f"Expected {result} for {item}, but got something else instead." |
| 76 | + self.assertEqual(tag_special_ingredients(item), (result), msg=error_message) |
80 | 77 |
|
81 | 78 | @pytest.mark.task(taskno=5)
|
82 | 79 | def test_compile_ingredients(self):
|
83 |
| - input_data = ingredients_only |
84 |
| - result_data = [VEGAN, VEGETARIAN, PALEO, KETO, OMNIVORE] |
85 |
| - number_of_variants = number_of_variants = range(1, len(input_data) + 1) |
| 80 | + test_data = zip(ingredients_only, [VEGAN, VEGETARIAN, PALEO, KETO, OMNIVORE]) |
86 | 81 |
|
87 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
| 82 | + for variant, (item, result) in enumerate(test_data, start=1): |
88 | 83 | with self.subTest(f"variation #{variant}", item=item, result=result):
|
89 |
| - self.assertEqual(compile_ingredients(item), (result)) |
| 84 | + error_message = "Expected a proper set of combined ingredients, but something went wrong." |
| 85 | + self.assertEqual(compile_ingredients(item), (result), msg=error_message) |
90 | 86 |
|
91 | 87 | @pytest.mark.task(taskno=6)
|
92 | 88 | def test_separate_appetizers(self):
|
93 |
| - input_data = dishes_and_appetizers |
94 |
| - result_data = dishes_cleaned |
95 |
| - number_of_variants = number_of_variants = range(1, len(input_data) + 1) |
| 89 | + test_data = zip(dishes_and_appetizers, dishes_cleaned) |
96 | 90 |
|
97 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
| 91 | + for variant, (item, result) in enumerate(test_data, start=1): |
98 | 92 | with self.subTest(f"variation #{variant}", item=item, result=result):
|
99 |
| - self.assertEqual(sorted(separate_appetizers(item[0], item[1])), (sorted(result))) |
| 93 | + error_message = "Expected only appetizers returned, but some dishes remain in the group." |
| 94 | + self.assertEqual(sorted(separate_appetizers(item[0], item[1])), (sorted(result)), msg=error_message) |
100 | 95 |
|
101 | 96 | @pytest.mark.task(taskno=7)
|
102 | 97 | def test_singleton_ingredients(self):
|
103 |
| - input_data = dishes_and_overlap |
104 |
| - result_data = singletons |
105 |
| - number_of_variants = number_of_variants = range(1, len(input_data) + 1) |
| 98 | + test_data = zip(dishes_and_overlap, singletons) |
106 | 99 |
|
107 |
| - for variant, item, result in zip(number_of_variants, input_data, result_data): |
| 100 | + for variant, (item, result) in enumerate(test_data, start=1): |
108 | 101 | with self.subTest(f"variation #{variant}", item=item, result=result):
|
109 |
| - self.assertEqual(singleton_ingredients(item[0], item[1]), (result)) |
| 102 | + error_message = "Expected only ingredients that belong to exactly one dish, but got multi-dish ingredients instead." |
| 103 | + self.assertEqual(singleton_ingredients(item[0], item[1]), (result), msg=error_message) |
0 commit comments