Exemple #1
0
    def test_magic_with_missing(self):
        t = Table()
        t.append(Record(x=1, y=2, z=3))
        t.append(Record(x=1, y=2, z=4))
        t.append(Record(x=2, y=1))
        t.append(Record(x=3, y=3))
        t.append(Record(x=2, y=2, z=3))
        t.append(Record(x=1, y=2, z=3))

        gt = Table()
        gt.append(Record(x=1, _=Table([t[0], t[1], t[5]])))
        gt.append(Record(x=2, _=Table([t[2], t[4]])))
        gt.append(Record(x=3, _=Table([t[3]])))

        assert t.magic(['x'], '_') == gt

        gt = Table()
        gt.append(Record(     _=Table([t[2], t[3]])))
        gt.append(Record(z=3, _=Table([t[0], t[4], t[5]])))
        gt.append(Record(z=4, _=Table([t[1]])))

        assert t.magic(['z'], '_') == gt
Exemple #2
0
    def test_magic(self):
        t = Table()
        t.append(Record(x=1, y=2, z=3))
        t.append(Record(x=1, y=2, z=4))
        t.append(Record(x=2, y=1, z=3))
        t.append(Record(x=3, y=3, z=4))
        t.append(Record(x=2, y=2, z=3))
        t.append(Record(x=1, y=2, z=3))

        gt = Table()
        gt.append(Record(x=1, _=Table([t[0], t[1], t[5]])))
        gt.append(Record(x=2, _=Table([t[2], t[4]])))
        gt.append(Record(x=3, _=Table([t[3]])))

        assert t.magic(['x'], '_') == gt

        gt = Table()
        gt.append(Record(x=1, y=2, _=Table([t[0], t[1], t[5]])))
        gt.append(Record(x=2, y=1, _=Table([t[2]])))
        gt.append(Record(x=2, y=2, _=Table([t[4]])))
        gt.append(Record(x=3, y=3, _=Table([t[3]])))

        assert t.magic(['x', 'y'], '_') == gt