MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / test_nontuple_row

Method test_nontuple_row

test/sql/test_resultset.py:1730–1754  ·  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

1728 eq_(r._mapping["_row"], "Hidden row")
1729
1730 def test_nontuple_row(self):
1731 """ensure the C version of BaseRow handles
1732 duck-type-dependent rows.
1733
1734
1735 As of 1.4 they are converted internally to tuples in any case.
1736
1737 """
1738
1739 class MyList:
1740 def __init__(self, data):
1741 self.internal_list = data
1742
1743 def __len__(self):
1744 return len(self.internal_list)
1745
1746 def __getitem__(self, i):
1747 return list.__getitem__(self.internal_list, i)
1748
1749 parent = SimpleResultMetaData(["key"])
1750 proxy = Row(parent, [None], parent._key_to_index, MyList(["value"]))
1751 eq_(list(proxy), ["value"])
1752 eq_(proxy[0], "value")
1753 eq_(proxy.key, "value")
1754 eq_(proxy._mapping["key"], "value")
1755
1756 @contextmanager
1757 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