From e956501e3444195d52226f6f378abaca3202fc8c Mon Sep 17 00:00:00 2001 From: BethanyG Date: Sun, 26 Sep 2021 12:34:00 -0700 Subject: [PATCH] Changed names of test classes to be ExerciseNameTest, for better readability in UI results. --- .../concept/black-jack/black_jack_test.py | 2 +- exercises/concept/card-games/lists_test.py | 288 ++++-------------- .../list_methods_test.py | 2 +- .../currency-exchange/exchange_test.py | 2 +- .../arcade_game_test.py | 2 +- .../inventory-management/dicts_test.py | 2 +- .../string_methods_test.py | 2 +- .../little-sisters-vocab/strings_test.py | 2 +- exercises/concept/log-levels/enums_test.py | 2 +- .../concept/making-the-grade/results.json | 48 --- .../meltdown-mitigation/conditionals_test.py | 2 +- .../pretty-leaflet/string_formatting_test.py | 2 +- .../concept/restaurant-rozalynn/none_test.py | 2 +- .../tisbury-treasure-hunt/tuples_test.py | 2 +- 14 files changed, 64 insertions(+), 296 deletions(-) delete mode 100644 exercises/concept/making-the-grade/results.json diff --git a/exercises/concept/black-jack/black_jack_test.py b/exercises/concept/black-jack/black_jack_test.py index 51c03e3173..0e12d27187 100644 --- a/exercises/concept/black-jack/black_jack_test.py +++ b/exercises/concept/black-jack/black_jack_test.py @@ -7,7 +7,7 @@ ) -class TestComparisons(unittest.TestCase): +class BlackJackTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_number_of_card(self): diff --git a/exercises/concept/card-games/lists_test.py b/exercises/concept/card-games/lists_test.py index 4f2131f840..a344ed891e 100644 --- a/exercises/concept/card-games/lists_test.py +++ b/exercises/concept/card-games/lists_test.py @@ -12,337 +12,153 @@ ) -class TestToRounds(unittest.TestCase): +class CardGamesTest(unittest.TestCase): @pytest.mark.task(taskno=1) - def test_instructions_example(self): - round_number = 27 - want = [27, 28, 29] - got = get_rounds(round_number) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - @pytest.mark.task(taskno=1) - def test_zero(self): + def test_round_number_zero(self): round_number = 0 want = [0, 1, 2] - got = get_rounds(round_number) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(want, get_rounds(round_number), + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=1) - def test_random_int(self): + def test_random_int_for_round_number(self): round_number = random.randint(0, 100) want = [round_number + i for i in range(3)] - got = get_rounds(round_number) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(get_rounds(round_number), want, + msg=f'Expected {want} but got an incorrect result.' ) - -class TestConcatenateRounds(unittest.TestCase): - @pytest.mark.task(taskno=2) - def test_empty(self): + def test_concatenate_empty_rounds(self): rounds_1 = [] rounds_2 = [] want = [] - self.assertEqual(concatenate_rounds(rounds_1, rounds_2), - want, - msg=f'Expected {want} but got an incorrect result.' - ) + self.assertEqual(concatenate_rounds(rounds_1, rounds_2), want, + msg=f'Expected {want} but got an incorrect result.' + ) @pytest.mark.task(taskno=2) - def test_other(self): + def test_concatenate_other_rounds(self): rounds_1 = [1, 2, 3] rounds_2 = [4, 5, 6] want = [1, 2, 3, 4, 5, 6] - self.assertEqual(concatenate_rounds(rounds_1, rounds_2), - want, - msg=f'Expected {want} but got an incorrect result.' - ) - - -class TestListContainsRound(unittest.TestCase): + self.assertEqual(concatenate_rounds(rounds_1, rounds_2), want, + msg=f'Expected {want} but got an incorrect result.' + ) @pytest.mark.task(taskno=3) - def test_instructions_example_1(self): - rounds = [27, 28, 29, 35, 36] - round_number = 29 - want = True - got = list_contains_round(rounds, round_number) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - @pytest.mark.task(taskno=3) - def test_instructions_example_2(self): - rounds = [27, 28, 29, 35, 36] - round_number = 30 - want = False - got = list_contains_round(rounds, round_number) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - @pytest.mark.task(taskno=3) - def test_empty(self): + def test_contains_empty_rounds(self): rounds = [] round_number = 1 want = False - got = list_contains_round(rounds, round_number) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(list_contains_round(rounds, round_number), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=3) - def test_other_true(self): + def test_contains_other_rounds_true(self): rounds = [1, 2, 3] round_number = 2 want = True - got = list_contains_round(rounds, round_number) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(list_contains_round(rounds, round_number), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=3) - def test_other_false(self): + def test_contains_other_rounds_false(self): rounds = [1, 2, 3] round_number = 0 want = False - got = list_contains_round(rounds, round_number) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(list_contains_round(rounds, round_number), want, + msg=f'Expected {want} but got an incorrect result.' ) - -class TestCardAverage(unittest.TestCase): - @pytest.mark.task(taskno=4) - def test_instructions_example(self): - hand = [5, 6, 7] - want = 6.0 - got = card_average(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - @pytest.mark.task(taskno=4) - def test_other(self): + def test_card_average_other(self): hand = [1, 2, 3, 4] want = 2.5 - got = card_average(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - -class TestApproxAverageIsAverage(unittest.TestCase): - - @pytest.mark.task(taskno=5) - def test_instructions_example_1(self): - hand = [1, 2, 3] - want = True - got = approx_average_is_average(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - @pytest.mark.task(taskno=5) - def test_instructions_example_2(self): - hand = [2, 3, 4, 8, 8] - want = True - got = approx_average_is_average(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(card_average(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=5) def test_instructions_example_3(self): hand = [1, 2, 3, 5, 9] want = False - got = approx_average_is_average(hand) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(approx_average_is_average(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=5) - def test_median_true(self): + def test_approx_average_median_true(self): hand = [1, 2, 4, 5, 8] want = True - got = approx_average_is_average(hand) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(approx_average_is_average(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=5) - def test_other_true(self): + def test_approx_average_other_true(self): hand = [2, 3, 4] want = True - got = approx_average_is_average(hand) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(approx_average_is_average(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=5) - def test_other_false(self): + def test_approx_average_other_false(self): hand = [2, 3, 4, 7, 8] - want = False - got = approx_average_is_average(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - -class TestAverageEvenIsAverageOdd(unittest.TestCase): - - @pytest.mark.task(taskno=6) - def test_instructions_example_1(self): - hand = [1, 2, 3] - want = True - got = average_even_is_average_odd(hand) + want= False - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(approx_average_is_average(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=6) - def test_instructions_example_2(self): - hand = [1, 2, 3, 4] - want = False - got = average_even_is_average_odd(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - @pytest.mark.task(taskno=6) - def test_other_true(self): + def test_avg_even_odd_other_true(self): hand = [5, 6, 7] - want = True - got = average_even_is_average_odd(hand) + want= True - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(average_even_is_average_odd(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=6) - def test_other_false(self): + def test_avg_even_odd_other_false(self): hand = [5, 6, 8] want = False - got = average_even_is_average_odd(hand) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - -class TestMaybeDoubleLast(unittest.TestCase): - - @pytest.mark.task(taskno=7) - def test_instructions_example_1(self): - hand = [5, 9, 11] - want = [5, 9, 22] - got = maybe_double_last(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' - ) - - @pytest.mark.task(taskno=7) - def test_instructions_example_2(self): - hand = [5, 9, 10] - want = [5, 9, 10] - got = maybe_double_last(hand) - - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(average_even_is_average_odd(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=7) - def test_other_doubles(self): + def test_maybe_double_last_other_doubles(self): hand = [1, 2, 11] want = [1, 2, 22] - got = maybe_double_last(hand) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(maybe_double_last(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) @pytest.mark.task(taskno=7) - def test_other_no_change(self): + def test_maybe_double_last_other_no_change(self): hand = [1, 2, 3] want = [1, 2, 3] - got = maybe_double_last(hand) - self.assertEqual( - want, - got, - msg=f'Expected {want} but got an incorrect result: {got!r}' + self.assertEqual(maybe_double_last(hand), want, + msg=f'Expected {want} but got an incorrect result.' ) diff --git a/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py b/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py index 0e92a1144f..36f45e9b10 100644 --- a/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py +++ b/exercises/concept/chaitanas-colossal-coaster/list_methods_test.py @@ -12,7 +12,7 @@ ) -class TestListMethods(unittest.TestCase): +class ListMethodsTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_add_me_to_the_queue_set_normal_queue(self): diff --git a/exercises/concept/currency-exchange/exchange_test.py b/exercises/concept/currency-exchange/exchange_test.py index e758f08ef9..000c2e5443 100644 --- a/exercises/concept/currency-exchange/exchange_test.py +++ b/exercises/concept/currency-exchange/exchange_test.py @@ -10,7 +10,7 @@ ) -class TestNumbers(unittest.TestCase): +class CurrencyExchangeTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_exchange_money(self): diff --git a/exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py b/exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py index a535ba8eac..12c491d9a2 100644 --- a/exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py +++ b/exercises/concept/ghost-gobble-arcade-game/arcade_game_test.py @@ -3,7 +3,7 @@ from arcade_game import eat_ghost, score, lose, win -class TestArcadeGame(unittest.TestCase): +class GhostGobbleGameTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_ghost_gets_eaten(self): diff --git a/exercises/concept/inventory-management/dicts_test.py b/exercises/concept/inventory-management/dicts_test.py index ec781e1416..f9243e3f25 100644 --- a/exercises/concept/inventory-management/dicts_test.py +++ b/exercises/concept/inventory-management/dicts_test.py @@ -3,7 +3,7 @@ from dicts import create_inventory, add_items, decrement_items, remove_item, list_inventory -class test_inventory(unittest.TestCase): +class InventoryTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_create_inventory(self): diff --git a/exercises/concept/little-sisters-essay/string_methods_test.py b/exercises/concept/little-sisters-essay/string_methods_test.py index f33e56e9c2..a74ccd0b7c 100644 --- a/exercises/concept/little-sisters-essay/string_methods_test.py +++ b/exercises/concept/little-sisters-essay/string_methods_test.py @@ -6,7 +6,7 @@ replace_word_choice) -class TestStringMethods(unittest.TestCase): +class LittleSistersEssayTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_capitalize_word(self): diff --git a/exercises/concept/little-sisters-vocab/strings_test.py b/exercises/concept/little-sisters-vocab/strings_test.py index 0e02f1bff5..f08194654d 100644 --- a/exercises/concept/little-sisters-vocab/strings_test.py +++ b/exercises/concept/little-sisters-vocab/strings_test.py @@ -6,7 +6,7 @@ noun_to_verb) -class TestStrings(unittest.TestCase): +class LittleSistersVocabTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_add_prefix_un(self): diff --git a/exercises/concept/log-levels/enums_test.py b/exercises/concept/log-levels/enums_test.py index a3fe5cfea9..ff46e5210b 100644 --- a/exercises/concept/log-levels/enums_test.py +++ b/exercises/concept/log-levels/enums_test.py @@ -10,7 +10,7 @@ ) -class TestEnums(unittest.TestCase): +class EnumsTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_parse_log_level_set_ing(self): diff --git a/exercises/concept/making-the-grade/results.json b/exercises/concept/making-the-grade/results.json deleted file mode 100644 index 953b99082f..0000000000 --- a/exercises/concept/making-the-grade/results.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "version": 3, - "status": "pass", - "tests": [ - { - "name": "MakingTheGrade > round scores", - "status": "pass", - "test_code": "input_data = [\n [90.33, 40.5, 55.44, 70.05, 30.55, 25.45, 80.45, 95.3, 38.7, 40.3],\n [],\n [50, 36.03, 76.92, 40.7, 43, 78.29, 63.58, 91, 28.6, 88.0],\n [.5],\n [1.5]\n]\nresult_data = [\n [40, 39, 95, 80, 25, 31, 70, 55, 40, 90],\n [],\n [88, 29, 91, 64, 78, 43, 41, 77, 36, 50],\n [0],\n [2]\n]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, scores, results in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", scores=scores, results=results):\n self.assertEqual(sorted(round_scores(scores)), sorted(results),\n msg=f'Expected: {results} but one or more {scores} were rounded incorrectly.')", - "task_id": 1 - }, - { - "name": "MakingTheGrade > no failed students", - "status": "pass", - "test_code": "scores = [89, 85, 42, 57, 90, 100, 95, 48, 70, 96]\nexpected = 0\nself.assertEqual(count_failed_students(scores), expected,\nmsg=f\"Expected the count to be {expected}, but the count wasn't calculated correctly.\")", - "task_id": 2 - }, - { - "name": "MakingTheGrade > some failed students", - "status": "pass", - "test_code": "scores = [40, 40, 35, 70, 30, 41, 90]\nexpected = 4\nself.assertEqual(count_failed_students(scores), expected,\n msg=f\"Expected the count to be {expected}, but the count wasn't calculated correctly.\")", - "task_id": 2 - }, - { - "name": "MakingTheGrade > above threshold", - "status": "pass", - "test_code": "input_data = [\n [40, 39, 95, 80, 25, 31, 70, 55, 40, 90],\n [88, 29, 91, 64, 78, 43, 41, 77, 36, 50],\n [100, 89],\n [88, 29, 91, 64, 78, 43, 41, 77, 36, 50],\n []\n]\nthresholds = [98, 80, 100, 78, 80]\nresult_data = [\n [],\n [88, 91],\n [100],\n [88, 91, 78],\n []\n]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, score, threshold, result in zip(number_of_variants, input_data, thresholds, result_data):\n with self.subTest(f\"variation #{variant}\", score=score, threshold=threshold, result=result):\n self.assertEqual(above_threshold(score, threshold), result,\n msg=f'Expected: {result} but the number of scores above {threshold} is incorrect.')", - "task_id": 3 - }, - { - "name": "MakingTheGrade > letter grades", - "status": "pass", - "test_code": "input_data = [100, 97, 85, 92, 81]\nresult_data = [\n [41, 56, 71, 86],\n [41, 55, 69, 83],\n [41, 52, 63, 74],\n [41, 54, 67, 80],\n [41, 51, 61, 71]\n]\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, highest, result in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", highest=highest, result=result):\n self.assertEqual(letter_grades(highest), result,\n msg=f'Expected: {result} but the grade thresholds for a high score of {highest} are incorrect.')", - "task_id": 4 - }, - { - "name": "MakingTheGrade > student ranking", - "status": "pass", - "test_code": "scores = [\n [100, 98, 92, 86, 70, 68, 67, 60, 50],\n [82],\n [88, 73],\n]\nnames = [\n ['Rui', 'Betty', 'Joci', 'Yoshi', 'Kora', 'Bern', 'Jan', 'Rose'],\n ['Betty'],\n ['Paul', 'Ernest'],\n]\nresult_data = [\n ['1. Rui: 100', '2. Betty: 98', '3. Joci: 92', '4. Yoshi: 86',\n '5. Kora: 70', '6. Bern: 68', '7. Jan: 67', '8. Rose: 60'],\n ['1. Betty: 82'],\n ['1. Paul: 88', '2. Ernest: 73']\n]\nnumber_of_variants = range(1, len(scores) + 1)\n\nfor variant, scores, names, results in zip(number_of_variants, scores, names, result_data):\n with self.subTest(f\"variation #{variant}\", scores=scores, names=names, results=results):\\\n self.assertEqual(student_ranking(scores, names), results,\n msg=f'Expected: {results} but the rankings were compiled incorrectly.')", - "task_id": 5 - }, - { - "name": "MakingTheGrade > perfect score", - "status": "pass", - "test_code": "input_data = [\n [['Rui', 60],['Joci', 58],['Sara', 91],['Kora', 93], ['Alex', 42],\n ['Jan', 81],['Lilliana', 40],['John', 60],['Bern', 28],['Vlad', 55]],\n\n [['Yoshi', 52],['Jan', 86], ['Raiana', 100], ['Betty', 60],\n ['Joci', 100],['Kora', 81],['Bern', 41], ['Rose', 94]],\n\n [['Joci', 100],['Vlad', 100],['Raiana', 100],['Alessandro', 100]],\n [['Jill', 30], ['Paul', 73],],\n []\n ]\nresult_data = [\n \"No perfect score.\",\n ['Raiana', 100],\n ['Joci', 100],\n \"No perfect score.\",\n \"No perfect score.\"\n]\n\nnumber_of_variants = range(1, len(input_data) + 1)\n\nfor variant, scores, results in zip(number_of_variants, input_data, result_data):\n with self.subTest(f\"variation #{variant}\", scores=scores, results=results):\n self.assertEqual(perfect_score(scores), results,\n msg=f'Expected: {results} but got something different for perfect scores.')", - "task_id": 6 - } - ] -} diff --git a/exercises/concept/meltdown-mitigation/conditionals_test.py b/exercises/concept/meltdown-mitigation/conditionals_test.py index acb83cd021..0ed92ffd33 100644 --- a/exercises/concept/meltdown-mitigation/conditionals_test.py +++ b/exercises/concept/meltdown-mitigation/conditionals_test.py @@ -5,7 +5,7 @@ fail_safe) -class TestConditionals(unittest.TestCase): +class MeltdownMitigationTest(unittest.TestCase): """Test cases for Meltdown mitigation exercise. """ diff --git a/exercises/concept/pretty-leaflet/string_formatting_test.py b/exercises/concept/pretty-leaflet/string_formatting_test.py index 98df9a2f2b..fe938e35a1 100644 --- a/exercises/concept/pretty-leaflet/string_formatting_test.py +++ b/exercises/concept/pretty-leaflet/string_formatting_test.py @@ -6,7 +6,7 @@ print_leaflet) -class TestStringFormatting(unittest.TestCase): +class PrettyLeafletTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_header(self): diff --git a/exercises/concept/restaurant-rozalynn/none_test.py b/exercises/concept/restaurant-rozalynn/none_test.py index 429a7fa6e6..d423fb0e70 100644 --- a/exercises/concept/restaurant-rozalynn/none_test.py +++ b/exercises/concept/restaurant-rozalynn/none_test.py @@ -10,7 +10,7 @@ ) -class TestNoneType(unittest.TestCase): +class RestaurantRozalynnTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_new_seating_chart_1(self): diff --git a/exercises/concept/tisbury-treasure-hunt/tuples_test.py b/exercises/concept/tisbury-treasure-hunt/tuples_test.py index f6dd7d24be..845aca5ba8 100644 --- a/exercises/concept/tisbury-treasure-hunt/tuples_test.py +++ b/exercises/concept/tisbury-treasure-hunt/tuples_test.py @@ -3,7 +3,7 @@ from tuples import get_coordinate, convert_coordinate, compare_records, create_record, clean_up -class TuplesTest(unittest.TestCase): +class TisburyTreasureTest(unittest.TestCase): @pytest.mark.task(taskno=1) def test_get_coordinate(self):