-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbite_152.py
More file actions
30 lines (24 loc) · 837 Bytes
/
bite_152.py
File metadata and controls
30 lines (24 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
DOT = '.'
TEXTS = ['Hello world', 'Welcome to PyBites',
'Decorators for fun and profit']
def strip_range(start, end):
@strip_range(3, 5)
def gen_output(text):
return text
def wrap(func):
def wrapped(text, *args, **kwargs):
_start = max(start, 0)
if end > 0:
_end = min(len(text), end)
else:
_end = 0
result = (text[:_start], text[_start:_end], text[_end:])
return func(f'{result[0]}{DOT * len(result[1])}{result[2]}')
return wrapped
return wrap
def test_strip_range(start, end, arg, expected):
@strip_range(start, end)
def gen_output(text):
return text
actual = gen_output(text=arg)
assert actual == expected