Пример #1
0
    def test_map(self):

        m = FieldFilter(drop=["a","c"])
        self.assertListEqual(["b", "d"], m.filter(self.fields).names())

        m = FieldFilter(keep=["a","c"])
        self.assertListEqual(["a", "c"], m.filter(self.fields).names())

        m = FieldFilter(rename={"a":"x","c":"y"})
        self.assertListEqual(["x", "b", "y", "d"], m.filter(self.fields).names())
Пример #2
0
    def test_selectors(self):
        m = FieldFilter(keep=["a","c"])
        self.assertListEqual([True, False, True, False],
                                m.field_mask(self.fields))

        m = FieldFilter(drop=["b","d"])
        self.assertListEqual([True, False, True, False],
                                m.field_mask(self.fields))

        m = FieldFilter()
        self.assertListEqual([True, True, True, True],
                                m.field_mask(self.fields))