Skip to content

Commit

Permalink
feat: implement callable return value #3
Browse files Browse the repository at this point in the history
  • Loading branch information
proofit404 committed Jan 2, 2021
1 parent 0d1f1fc commit 4294426
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/_primitives/callable.py
@@ -1,6 +1,12 @@
class Callable:
"""An object appropriate to fake functions and methods."""

def __init__(self, *args):
if args:
self.return_value = args[0]
else:
self.return_value = None

def __call__(self):
"""Return predefined value."""
pass
return self.return_value
6 changes: 6 additions & 0 deletions tests/test_callable.py
Expand Up @@ -11,3 +11,9 @@ def test_empty_callable_object():
"""
func = Callable()
assert func() is None


def test_callable_object_return_value():
"""`Callable` object should return value passed to it constructor."""
func = Callable("Hello, John")
assert func() == "Hello, John"

0 comments on commit 4294426

Please sign in to comment.