Exemplo n.º 1
0
    def test_where_preserves_rows(self):
        table = Table(self.rows, self.columns)
        table2 = table.where(lambda r: r['one'] == 1)
        table3 = table2.where(lambda r: r['one'] == 1)

        self.assertIs(table.rows[0], table2.rows[0])
        self.assertIs(table2.rows[0], table3.rows[0])
Exemplo n.º 2
0
    def test_where_preserves_rows(self):
        table = Table(self.rows, self.columns)
        table2 = table.where(lambda r: r['one'] == 1)
        table3 = table2.where(lambda r: r['one'] == 1)

        self.assertIs(table.rows[0], table2.rows[0])
        self.assertIs(table2.rows[0], table3.rows[0])
Exemplo n.º 3
0
    def test_where(self):
        table = Table(self.rows, self.columns)

        new_table = table.where(lambda r: r['one'] in (2, None))

        self.assertIsNot(new_table, table)
        self.assertEqual(len(new_table.rows), 2)
        self.assertSequenceEqual(new_table.rows[0], (2, 3, 'b'))
        self.assertSequenceEqual(new_table.columns['one'], (2, None))
Exemplo n.º 4
0
    def test_where(self):
        table = Table(self.rows, self.columns)

        new_table = table.where(lambda r: r['one'] in (2, None))

        self.assertIsNot(new_table, table)
        self.assertEqual(len(new_table.rows), 2)
        self.assertSequenceEqual(new_table.rows[0], (2, 3, 'b'))
        self.assertSequenceEqual(new_table.columns['one'], (2, None))
Exemplo n.º 5
0
    def test_where_with_row_names(self):
        table = Table(self.rows, self.columns, row_names='three')
        new_table = table.where(lambda r: r['one'] in (2, None))

        self.assertSequenceEqual(table.rows['a'], (1, 4, 'a'))
        self.assertSequenceEqual(new_table.row_names, ('b', u'👍'))
Exemplo n.º 6
0
    def test_where_with_row_names(self):
        table = Table(self.rows, self.columns, row_names='three')
        new_table = table.where(lambda r: r['one'] in (2, None))

        self.assertSequenceEqual(table.rows['a'], (1, 4, 'a'))
        self.assertSequenceEqual(new_table.row_names, ('b', u'👍'))