diff --git a/homework/tests.py b/homework/tests.py index 90a295b..e679660 100644 --- a/homework/tests.py +++ b/homework/tests.py @@ -1,3 +1,6 @@ +import math + + def test_even_fucntion(): """ Необходимо реализовать функцию even_filter, которая получает неограниченное количество аргументов @@ -5,7 +8,8 @@ def test_even_fucntion(): """ def even_filter(*args): - pass + even = [x for x in args if x % 2 == 0] + return even assert even_filter(1, 2, 3, 4, 5, 6) == [2, 4, 6] @@ -16,7 +20,10 @@ def test_increment_decorator(): декрорируемую функцию. """ def increment_derocator(func): - pass + def wrap(arg1): + arg2 = arg1 + 1 + return func(arg2) + return wrap @increment_derocator def returner(value): @@ -41,10 +48,12 @@ def __init__(self, x, y): class Segment(): def __init__(self, p1, p2): - pass + self.p1 = p1 + self.p2 = p2 def length(self): - return 0 + dist = math.hypot(self.p2.x - self.p1.x, self.p2.y - self.p1.y) + return dist p1 = Point(0, 0) p2 = Point(3, 4)