def test_duck_call_raise(): """ Should raise TypeError """ obj = Obj(42) duck = Duck(obj) with pytest.raises(TypeError): duck.call([["bad", "arguments"]])
def test_duck_call_default(): """ Should return default value. """ obj = Obj(42) duck = Duck(obj) assert duck.call([["bad", "arguments"]], default=1234) == 1234
def test_duck_call(): """ Should return the result of the first successful call the callable object. """ obj = Obj(42) duck = Duck(obj) assert duck.call([["foo"]], [], [["hello1", "world1"]], [["hello"], { "argument2": "world" }]) == obj("hello", argument2="world")
def test_duck_noargs_call(): """ Should return the result of the first successful call the callable object. """ def some_func(): return "hello!" duck = Duck(some_func) assert (duck.call([["foo"]], [], [["hello1", "world1"]], [["hello"], { "argument2": "world" }]) == "hello!")