from functools import wraps def greetings(func): @wraps(func) def inner(*args, **kwargs): return f'Hello, {func(*args, **kwargs)}!' return inner @greetings def world(): return "world" # world()
class Greetings(object):- from functools import wraps
def __init__(self, the_greeter):self.the_greeter = the_greeterdef __call__(self, *args, **kwargs):return '{} World'.format(self.the_greeter.__name__)- def greetings(func):
- @wraps(func)
- def inner(*args, **kwargs):
- return f'Hello, {func(*args, **kwargs)}!'
- return inner
@Greetingsdef Hello():pass# Hello()- @greetings
- def world():
- return "world"
- # world()
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Fixed Tests") def basic_tests(): @test.it('Basic Test Cases') def basic_test_cases(): test.assert_equals(world(), 'Hello, world!')
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Fixed Tests")
- def basic_tests():
- @test.it('Basic Test Cases')
- def basic_test_cases():
test.assert_equals(Hello(), 'Hello World')- test.assert_equals(world(), 'Hello, world!')