From dd20f56bc9a32f0c3afc545ed519dce8b028792c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 30 Mar 2016 17:27:53 -0400 Subject: - make sure negative row indexes are based on the size of the number of columns we're actually reporting on - add more tests for negative row index - changelog/migration --- test/engine/test_execute.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'test/engine') diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index aadd170f3..66903bef3 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -951,24 +951,32 @@ class ResultProxyTest(fixtures.TestBase): {'key': (None, None, 0), 0: (None, None, 0)}) assert isinstance(row, collections.Sequence) - def test_rowproxy_getitem(self): - metadata = MetaData() - metadata.bind = 'sqlite://' - values = Table('users', metadata, + @testing.provide_metadata + def test_rowproxy_getitem_indexes_compiled(self): + values = Table('users', self.metadata, Column('key', String(10), primary_key=True), Column('value', String(10))) values.create() - values.insert().execute(key='One', value='Uno') - row = values.select().execute().fetchone() - - assert row['key'] == 'One' - assert row['value'] == 'Uno' - assert row[0] == 'One' - assert row[1] == 'Uno' - assert row[-2] == 'One' - assert row[-1] == 'Uno' - assert row[1:0:-1] == ('Uno',) + testing.db.execute(values.insert(), dict(key='One', value='Uno')) + row = testing.db.execute(values.select()).first() + eq_(row['key'], 'One') + eq_(row['value'], 'Uno') + eq_(row[0], 'One') + eq_(row[1], 'Uno') + eq_(row[-2], 'One') + eq_(row[-1], 'Uno') + eq_(row[1:0:-1], ('Uno',)) + + def test_rowproxy_getitem_indexes_raw(self): + row = testing.db.execute("select 'One' as key, 'Uno' as value").first() + eq_(row['key'], 'One') + eq_(row['value'], 'Uno') + eq_(row[0], 'One') + eq_(row[1], 'Uno') + eq_(row[-2], 'One') + eq_(row[-1], 'Uno') + eq_(row[1:0:-1], ('Uno',)) @testing.requires.cextensions def test_row_c_sequence_check(self): -- cgit v1.2.1