diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-10-29 14:38:34 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2015-10-29 14:38:34 -0400 |
commit | 382950b70150434f124b6dc27df2b360e7d0331e (patch) | |
tree | 4dcbbc1e5f4aa24ffc3a1c522c3bd77cbeeaf0cd /test/base/test_utils.py | |
parent | 98c1dcc6bcade313a254fe11e8efa3c5b5ad959e (diff) | |
parent | e31211c578854d63128a30c036e40eee5c43edc7 (diff) | |
download | sqlalchemy-382950b70150434f124b6dc27df2b360e7d0331e.tar.gz |
Merge branch 'pr204'
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 8074de53e..c1027ec8e 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -313,6 +313,75 @@ class MemoizedAttrTest(fixtures.TestBase): eq_(canary.mock_calls, [mock.call.attr(), mock.call.method()]) +class WrapCallableTest(fixtures.TestBase): + def test_wrapping_update_wrapper_fn(self): + def my_fancy_default(): + """run the fancy default""" + return 10 + + c = util.wrap_callable(lambda: my_fancy_default, my_fancy_default) + + eq_(c.__name__, "my_fancy_default") + eq_(c.__doc__, "run the fancy default") + + def test_wrapping_update_wrapper_fn_nodocstring(self): + def my_fancy_default(): + return 10 + + c = util.wrap_callable(lambda: my_fancy_default, my_fancy_default) + eq_(c.__name__, "my_fancy_default") + eq_(c.__doc__, None) + + def test_wrapping_update_wrapper_cls(self): + class MyFancyDefault(object): + """a fancy default""" + + def __call__(self): + """run the fancy default""" + return 10 + + def_ = MyFancyDefault() + c = util.wrap_callable(lambda: def_(), def_) + + eq_(c.__name__, "MyFancyDefault") + eq_(c.__doc__, "run the fancy default") + + def test_wrapping_update_wrapper_cls_noclsdocstring(self): + class MyFancyDefault(object): + + def __call__(self): + """run the fancy default""" + return 10 + + def_ = MyFancyDefault() + c = util.wrap_callable(lambda: def_(), def_) + eq_(c.__name__, "MyFancyDefault") + eq_(c.__doc__, "run the fancy default") + + def test_wrapping_update_wrapper_cls_nomethdocstring(self): + class MyFancyDefault(object): + """a fancy default""" + + def __call__(self): + return 10 + + def_ = MyFancyDefault() + c = util.wrap_callable(lambda: def_(), def_) + eq_(c.__name__, "MyFancyDefault") + eq_(c.__doc__, "a fancy default") + + def test_wrapping_update_wrapper_cls_noclsdocstring_nomethdocstring(self): + class MyFancyDefault(object): + + def __call__(self): + return 10 + + def_ = MyFancyDefault() + c = util.wrap_callable(lambda: def_(), def_) + eq_(c.__name__, "MyFancyDefault") + eq_(c.__doc__, None) + + class ToListTest(fixtures.TestBase): def test_from_string(self): eq_( |