MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / test_nontuple_row

Method test_nontuple_row

test/sql/test_resultset.py:1795–1819  ·  view source on GitHub ↗

ensure the C version of BaseRow handles duck-type-dependent rows. As of 1.4 they are converted internally to tuples in any case.

(self)

Source from the content-addressed store, hash-verified

1793 eq_(r._mapping["_row"], "Hidden row")
1794
1795 def test_nontuple_row(self):
1796 """ensure the C version of BaseRow handles
1797 duck-type-dependent rows.
1798
1799
1800 As of 1.4 they are converted internally to tuples in any case.
1801
1802 """
1803
1804 class MyList:
1805 def __init__(self, data):
1806 self.internal_list = data
1807
1808 def __len__(self):
1809 return len(self.internal_list)
1810
1811 def __getitem__(self, i):
1812 return list.__getitem__(self.internal_list, i)
1813
1814 parent = SimpleResultMetaData(["key"])
1815 proxy = Row(parent, [None], parent._key_to_index, MyList(["value"]))
1816 eq_(list(proxy), ["value"])
1817 eq_(proxy[0], "value")
1818 eq_(proxy.key, "value")
1819 eq_(proxy._mapping["key"], "value")
1820
1821 @contextmanager
1822 def cursor_wrapper(self, engine):

Callers

nothing calls this directly

Calls 4

RowClass · 0.90
eq_Function · 0.90
MyListClass · 0.70

Tested by

no test coverage detected