summaryrefslogtreecommitdiff
path: root/test/base/test_utils.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-10-29 14:38:34 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-10-29 14:38:34 -0400
commit382950b70150434f124b6dc27df2b360e7d0331e (patch)
tree4dcbbc1e5f4aa24ffc3a1c522c3bd77cbeeaf0cd /test/base/test_utils.py
parent98c1dcc6bcade313a254fe11e8efa3c5b5ad959e (diff)
parente31211c578854d63128a30c036e40eee5c43edc7 (diff)
downloadsqlalchemy-382950b70150434f124b6dc27df2b360e7d0331e.tar.gz
Merge branch 'pr204'
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r--test/base/test_utils.py69
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_(