def test_duplicate_under_another_name(self): transform = m.rename(d='a', a='a') self.assertListEqual( [ ('a', 'd', 'b'), (1, 1, 2) ], list(transform([ ('a', 'b'), (1, 2) ])))
def test_rename_with_special_characters(self): transform = m.rename({'new @!': 'old !'}) self.assertListEqual( [ ('a', 'b', 'new @!', 'd'), (1, 2, 3, 4) ], list(transform([ ('a', 'b', 'old !', 'd'), (1, 2, 3, 4) ])))
def test_overwrite_existing_column(self): transform = m.rename(b='a') self.assertListEqual( [ ('b', 'c', 'd'), (1, 3, 4) ], list(transform([ ('a', 'b', 'c', 'd'), (1, 2, 3, 4) ])))
def test_swap_labels(self): transform = m.rename(b='a', a='b') self.assertListEqual( [ ('b', 'a', 'c', 'd'), (1, 2, 3, 4) ], list(transform([ ('a', 'b', 'c', 'd'), (1, 2, 3, 4) ])))
def test_in_place(self): transform = m.rename(a1='a', b1='b') self.assertListEqual( [ ('a1', 'b1', 'c', 'd'), (1, 2, 3, 4) ], list(transform([ ('a', 'b', 'c', 'd'), (1, 2, 3, 4) ])))