diff options
author | jvanasco <jonathan@2xlp.com> | 2014-10-17 19:37:47 -0400 |
---|---|---|
committer | jvanasco <jonathan@2xlp.com> | 2014-10-17 19:37:47 -0400 |
commit | efca4af93603faa7abfeacbab264cad85ee4105c (patch) | |
tree | c98b87e0a489c668acd119800c8a946dc7fdf9d4 /test/base/test_utils.py | |
parent | 4da020dae324cb871074e302f4840e8731988be0 (diff) | |
parent | 61a4a89d993eda1d3168b501ba9ed8d94ea9b5f8 (diff) | |
download | sqlalchemy-efca4af93603faa7abfeacbab264cad85ee4105c.tar.gz |
Merged zzzeek/sqlalchemy into master
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r-- | test/base/test_utils.py | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py index a378b0160..f75c5cbe9 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -6,7 +6,7 @@ from sqlalchemy.testing import eq_, is_, ne_, fails_if from sqlalchemy.testing.util import picklers, gc_collect from sqlalchemy.util import classproperty, WeakSequence, get_callable_argspec from sqlalchemy.sql import column - +from sqlalchemy.util import langhelpers class _KeyedTupleTest(object): @@ -1274,6 +1274,43 @@ class DuckTypeCollectionTest(fixtures.TestBase): is_(util.duck_type_collection(instance), None) +class PublicFactoryTest(fixtures.TestBase): + + def _fixture(self): + class Thingy(object): + def __init__(self, value): + "make a thingy" + self.value = value + + @classmethod + def foobar(cls, x, y): + "do the foobar" + return Thingy(x + y) + + return Thingy + + def test_classmethod(self): + Thingy = self._fixture() + foob = langhelpers.public_factory( + Thingy.foobar, ".sql.elements.foob") + eq_(foob(3, 4).value, 7) + eq_(foob(x=3, y=4).value, 7) + eq_(foob.__doc__, "do the foobar") + eq_(foob.__module__, "sqlalchemy.sql.elements") + assert Thingy.foobar.__doc__.startswith("This function is mirrored;") + + def test_constructor(self): + Thingy = self._fixture() + foob = langhelpers.public_factory( + Thingy, ".sql.elements.foob") + eq_(foob(7).value, 7) + eq_(foob(value=7).value, 7) + eq_(foob.__doc__, "make a thingy") + eq_(foob.__module__, "sqlalchemy.sql.elements") + assert Thingy.__init__.__doc__.startswith( + "Construct a new :class:`.Thingy` object.") + + class ArgInspectionTest(fixtures.TestBase): def test_get_cls_kwargs(self): |