def __init__(self): self.dehydration_functions = {} self.dehydration_functions.update({ Point: dehydrate_point, Date: dehydrate_date, date: dehydrate_date, Time: dehydrate_time, time: dehydrate_time, DateTime: dehydrate_datetime, datetime: dehydrate_datetime, Duration: dehydrate_duration, timedelta: dehydrate_timedelta, }) # Allow dehydration from any direct Point subclass self.dehydration_functions.update({cls: dehydrate_point for cls in Point.__subclasses__()})
def test_number_arguments(self): for argument in ((1, 2), (1.2, 2.1)): with self.subTest(): p = Point(argument) assert tuple(p) == argument
def test_wrong_type_arguments(self): for argument in (("a", "b"), ({"x": 1.0, "y": 2.0})): with self.subTest(): with self.assertRaises(ValueError): Point(argument)