93
94
e.execute("select 1")
98
class RowProxyTest(fixtures.TestBase):
99
def _rowproxy_fixture(self, keys, processors, row):
100
from sqlalchemy.engine.base import RowProxy
101
class MockMeta(object):
105
metadata = MockMeta()
108
for index, (keyobjs, processor, values) in \
109
enumerate(zip(keys, processors, row)):
111
keymap[key] = (processor, key, index)
112
keymap[index] = (processor, key, index)
113
return RowProxy(metadata, row, processors, keymap)
115
def _test_getitem_value_refcounts(self, seq_factory):
117
col1, col2 = object(), object()
120
value1, value2 = "x", "y"
121
row = self._rowproxy_fixture(
122
[(col1, "a"),(col2, "b")],
124
seq_factory([value1, value2])
127
v1_refcount = sys.getrefcount(value1)
128
v2_refcount = sys.getrefcount(value2)
137
eq_(sys.getrefcount(value1), v1_refcount)
138
eq_(sys.getrefcount(value2), v2_refcount)
140
def test_value_refcounts_pure_tuple(self):
141
self._test_getitem_value_refcounts(tuple)
143
def test_value_refcounts_custom_seq(self):
144
class CustomSeq(object):
145
def __init__(self, data):
148
def __getitem__(self, item):
149
return self.data[item]
152
return iter(self.data)
153
self._test_getitem_value_refcounts(CustomSeq)