Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

My homework #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions homework/tests.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import math


def test_even_fucntion():
"""
Необходимо реализовать функцию even_filter, которая получает неограниченное количество аргументов
и возвращает из них только четные.
"""

def even_filter(*args):
pass
result = []
for i in args:
if i % 2 == 0:
result.append(i)
return result

assert even_filter(1, 2, 3, 4, 5, 6) == [2, 4, 6]

Expand All @@ -16,7 +23,9 @@ def test_increment_decorator():
декрорируемую функцию.
"""
def increment_derocator(func):
pass
def wrapper(value):
return func(value + 1)
return wrapper

@increment_derocator
def returner(value):
Expand All @@ -25,6 +34,7 @@ def returner(value):
assert returner(1) == 2



def test_point_segment_class():
"""
Дано: есть класс Point, описывающий точку на плоскости. Необходимо закончить класс Segment, описывающий отрезок,
Expand All @@ -38,14 +48,17 @@ def __init__(self, x, y):
self.x = x
self.y = y


class Segment():
def __init__(self, p1, p2):
pass
self.p1 = p1
self.p2 = p2

def length(self):
return 0
value = math.sqrt(math.pow(self.p1.x - self.p2.x, 2) + math.pow(self.p1.y - self.p2.y, 2))
return value


p1 = Point(0, 0)
p2 = Point(3, 4)
assert Segment(p1, p2).length() == 5.0
Expand Down