From 2435f272c0f0f14ec19bbd96736fb7383f4aaa09 Mon Sep 17 00:00:00 2001 From: Nils Pukropp Date: Fri, 23 Feb 2024 16:00:49 +0100 Subject: [PATCH] fixed messages --- src/ex2_dictionary.md | 12 ++++++++---- src/ex2_dictionary.py | 5 ++--- src/test_dictionary.py | 19 ++++++++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/ex2_dictionary.md b/src/ex2_dictionary.md index 8917911..1a76742 100644 --- a/src/ex2_dictionary.md +++ b/src/ex2_dictionary.md @@ -1,7 +1,11 @@ !!!autogeneriert!!! -## exercise 2 - dictionary - (0/20) +## exercise 2 - dictionary - (11.5/20) -### a) calculate_price (0/10) +### a) calculate_price (6/10) +- Preis wird nicht in Euro (float) ausgegeben [`-2`] +- Preis wird nicht korrekt berechnet [`-2`] - -### b) by_amount (0/10) +### b) by_amount (5.5/10) +- `by_amount` hat inkorrekte Typannotationen [`-0.5`] +- nicht überprüft ob Produkte in `articles` enthalten [`-2`] +- `by_amount` wird nicht korrekt berechnet [`-2`] \ No newline at end of file diff --git a/src/ex2_dictionary.py b/src/ex2_dictionary.py index ef19d95..4e4bac0 100644 --- a/src/ex2_dictionary.py +++ b/src/ex2_dictionary.py @@ -1,8 +1,5 @@ -import os - # DO NOT CHANGE THE IMPORTS! - def calculate_price(articles: dict[str, int], cart: dict[str, int]) -> float: price = 0 for name, amount in cart.items(): @@ -32,3 +29,5 @@ if __name__ == "__main__": assert by_amount(articles_dict, cart_dict) == { 2: ['apples', 'oranges'], 1: ['lemons']} + + diff --git a/src/test_dictionary.py b/src/test_dictionary.py index c7e1b0e..c932d24 100644 --- a/src/test_dictionary.py +++ b/src/test_dictionary.py @@ -1,5 +1,4 @@ import argparse -import sys from copy import deepcopy from enum import Enum @@ -24,7 +23,6 @@ def test_imported_modules(): assert len(list(imported_modules_of(ex2_dictionary))) == 0 -@pytest.mark.dependency(depends=[Task.MODULES]) @pytest.mark.dependency(name=Task.A) @pytest.mark.timeout(10) @eidp_test("`calculate_price` nicht implementiert", -10, Task.A) @@ -32,7 +30,6 @@ def test_calculate_price_implemented(): from ex2_dictionary import calculate_price as _ -@pytest.mark.dependency(depends=[Task.MODULES]) @pytest.mark.dependency(name=Task.B) @pytest.mark.timeout(10) @eidp_test("`by_amount` nicht implementiert", -10, Task.B) @@ -186,14 +183,14 @@ if __name__ == '__main__': for name, f in vals.items() if callable(f) and hasattr(f, "is_test")]) failed = list(map(lambda m: m[1], filter( lambda m: m[0] in failed, tests.items()))) - failed_a = map(lambda f: f.minus_points, filter( - lambda f: f.task == Task.A or f.task == Task.MODULES, failed)) - failed_b = map(lambda f: f.minus_points, filter( - lambda f: f.task == Task.B or f.task == Task.MODULES, failed)) - points_a = max(10 + sum(failed_a), 0) - points_b = max(10 + sum(failed_b), 0) - msg_a = "\n".join(map( - lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_a)) + failed_a = list(filter(lambda f: f.task == + Task.A or f.task == Task.MODULES, failed)) + failed_b = list(filter(lambda f: f.task == + Task.B or f.task == Task.MODULES, failed)) + points_a = max(10 + sum(map(lambda f: f.minus_points, failed_a)), 0) + points_b = max(10 + sum(map(lambda f: f.minus_points, failed_b)), 0) + msg_a = "\n".join( + map(lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_a)) msg_b = "\n".join( map(lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_b)) content = f"""\