Я пишу тесты, используя Assert. Как сравнить с TypeError?
Функция
def calc_of_the_cost_of_delivery(distance: int, size: str, fragility: bool, workload: str) -> int:
....
if distance > 30:
raise 'The distance may not be more than 30 km for a soft cargo'
elif fragility:
cost += 300
....
return max(min_delivery_cost, cost)
Тесты
if __name__ == '__main__':
assert (calc_of_the_cost_of_delivery(20, 'small', True, 'medium')) == 720
assert (calc_of_the_cost_of_delivery(20, 'big', False, 'other')) == 400
assert (calc_of_the_cost_of_delivery(50, 'small', True, 'high')) == ***TypeError***
Подробнее здесь: https://stackoverflow.com/questions/784 ... ing-assert