fixed messages

This commit is contained in:
2024-02-23 16:00:49 +01:00
parent 94f5f83f08
commit 2435f272c0
3 changed files with 18 additions and 18 deletions

View File

@ -1,7 +1,11 @@
!!!autogeneriert!!! !!!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 (5.5/10)
### b) by_amount (0/10) - `by_amount` hat inkorrekte Typannotationen [`-0.5`]
- nicht überprüft ob Produkte in `articles` enthalten [`-2`]
- `by_amount` wird nicht korrekt berechnet [`-2`]

View File

@ -1,8 +1,5 @@
import os
# DO NOT CHANGE THE IMPORTS! # DO NOT CHANGE THE IMPORTS!
def calculate_price(articles: dict[str, int], cart: dict[str, int]) -> float: def calculate_price(articles: dict[str, int], cart: dict[str, int]) -> float:
price = 0 price = 0
for name, amount in cart.items(): for name, amount in cart.items():
@ -32,3 +29,5 @@ if __name__ == "__main__":
assert by_amount(articles_dict, cart_dict) == { assert by_amount(articles_dict, cart_dict) == {
2: ['apples', 'oranges'], 1: ['lemons']} 2: ['apples', 'oranges'], 1: ['lemons']}

View File

@ -1,5 +1,4 @@
import argparse import argparse
import sys
from copy import deepcopy from copy import deepcopy
from enum import Enum from enum import Enum
@ -24,7 +23,6 @@ def test_imported_modules():
assert len(list(imported_modules_of(ex2_dictionary))) == 0 assert len(list(imported_modules_of(ex2_dictionary))) == 0
@pytest.mark.dependency(depends=[Task.MODULES])
@pytest.mark.dependency(name=Task.A) @pytest.mark.dependency(name=Task.A)
@pytest.mark.timeout(10) @pytest.mark.timeout(10)
@eidp_test("`calculate_price` nicht implementiert", -10, Task.A) @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 _ from ex2_dictionary import calculate_price as _
@pytest.mark.dependency(depends=[Task.MODULES])
@pytest.mark.dependency(name=Task.B) @pytest.mark.dependency(name=Task.B)
@pytest.mark.timeout(10) @pytest.mark.timeout(10)
@eidp_test("`by_amount` nicht implementiert", -10, Task.B) @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")]) for name, f in vals.items() if callable(f) and hasattr(f, "is_test")])
failed = list(map(lambda m: m[1], filter( failed = list(map(lambda m: m[1], filter(
lambda m: m[0] in failed, tests.items()))) lambda m: m[0] in failed, tests.items())))
failed_a = map(lambda f: f.minus_points, filter( failed_a = list(filter(lambda f: f.task ==
lambda f: f.task == Task.A or f.task == Task.MODULES, failed)) Task.A or f.task == Task.MODULES, failed))
failed_b = map(lambda f: f.minus_points, filter( failed_b = list(filter(lambda f: f.task ==
lambda f: f.task == Task.B or f.task == Task.MODULES, failed)) Task.B or f.task == Task.MODULES, failed))
points_a = max(10 + sum(failed_a), 0) points_a = max(10 + sum(map(lambda f: f.minus_points, failed_a)), 0)
points_b = max(10 + sum(failed_b), 0) points_b = max(10 + sum(map(lambda f: f.minus_points, failed_b)), 0)
msg_a = "\n".join(map( msg_a = "\n".join(
lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_a)) map(lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_a))
msg_b = "\n".join( msg_b = "\n".join(
map(lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_b)) map(lambda f: f"- {f.msg} [`{f.minus_points}`]", failed_b))
content = f"""\ content = f"""\