summaryrefslogtreecommitdiff
path: root/test/base/test_utils.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-07-20 20:35:04 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2015-07-20 20:35:04 -0400
commit575f080850a0a061ccb7ac40e3ea1fbf6b0fedf4 (patch)
tree4c3f6020e3d1a6bd4d761d31f996665fde826dce /test/base/test_utils.py
parenta4b8aa320d63f7c0dc7c70dfce56f0af593d95f0 (diff)
downloadsqlalchemy-575f080850a0a061ccb7ac40e3ea1fbf6b0fedf4.tar.gz
- Fixed an issue where a particular base class within utils
didn't implement ``__slots__``, and therefore meant all subclasses of that class didn't either, negating the rationale for ``__slots__`` to be in use. Didn't cause any issue except on IronPython which apparently does not implement ``__slots__`` behavior compatibly with cPython. Fixes #3494
Diffstat (limited to 'test/base/test_utils.py')
-rw-r--r--test/base/test_utils.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/test/base/test_utils.py b/test/base/test_utils.py
index 256f52850..8074de53e 100644
--- a/test/base/test_utils.py
+++ b/test/base/test_utils.py
@@ -2,13 +2,14 @@ import copy
from sqlalchemy import util, sql, exc, testing
from sqlalchemy.testing import assert_raises, assert_raises_message, fixtures
-from sqlalchemy.testing import eq_, is_, ne_, fails_if
+from sqlalchemy.testing import eq_, is_, ne_, fails_if, mock
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
import inspect
+
class _KeyedTupleTest(object):
def _fixture(self, values, labels):
@@ -284,6 +285,33 @@ class MemoizedAttrTest(fixtures.TestBase):
eq_(f1.bar(), 20)
eq_(val[0], 21)
+ def test_memoized_slots(self):
+ canary = mock.Mock()
+
+ class Foob(util.MemoizedSlots):
+ __slots__ = ('foo_bar', 'gogo')
+
+ def _memoized_method_gogo(self):
+ canary.method()
+ return "gogo"
+
+ def _memoized_attr_foo_bar(self):
+ canary.attr()
+ return "foobar"
+
+ f1 = Foob()
+ assert_raises(AttributeError, setattr, f1, "bar", "bat")
+
+ eq_(f1.foo_bar, "foobar")
+
+ eq_(f1.foo_bar, "foobar")
+
+ eq_(f1.gogo(), "gogo")
+
+ eq_(f1.gogo(), "gogo")
+
+ eq_(canary.mock_calls, [mock.call.attr(), mock.call.method()])
+
class ToListTest(fixtures.TestBase):
def test_from_string(self):