def test_skips_did_not_handle(self): with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) obj1 = fudge.Fake().expects('func').returns(DID_NOT_HANDLE) obj2 = fudge.Fake().expects('func').with_args('arg1', kw=1) p = Proxy([obj1, obj2], 'func') p('arg1', kw=1)
def test_returns_expected_value(self): obj = fudge.Fake().expects('func').returns("proxy returned me") p = Proxy([obj], 'func') self.assertEqual(p(), "proxy returned me")
def test_skips_backenddidnothandle(self): obj1 = fudge.Fake().expects('func').raises(BackendDidNotHandle) obj2 = fudge.Fake().expects('func').with_args('arg1', kw=1) p = Proxy([obj1, obj2], 'func') p('arg1', kw=1)
def test_only_uses_first_possibility_that_works(self): obj1 = fudge.Fake().expects('func').with_args('arg1', kw=1).returns(1) obj2 = fudge.Fake().provides('func').returns(2) p = Proxy([obj1, obj2], 'func') self.assertEqual(p('arg1', kw=1), 1)
def test_calls_attr_with_args_and_kwargs(self): obj = fudge.Fake().expects('func').with_args('arg1', 'arg2', kw=1) p = Proxy([obj], 'func') p('arg1', 'arg2', kw=1)
def test_calls_attr_on_possible(self): obj = fudge.Fake().expects('func') p = Proxy([obj], 'func') p()
def test_empty_proxy(self): p = Proxy([], 'func') self.assertIsNone(p())