| 1882 | ] |
| 1883 | ) |
| 1884 | def test_table_rename_columns(cls): |
| 1885 | data = [ |
| 1886 | pa.array(range(5)), |
| 1887 | pa.array([-10, -5, 0, 5, 10]), |
| 1888 | pa.array(range(5, 10)) |
| 1889 | ] |
| 1890 | table = cls.from_arrays(data, names=['a', 'b', 'c']) |
| 1891 | assert table.column_names == ['a', 'b', 'c'] |
| 1892 | |
| 1893 | expected = cls.from_arrays(data, names=['eh', 'bee', 'sea']) |
| 1894 | |
| 1895 | # Testing with list |
| 1896 | t2 = table.rename_columns(['eh', 'bee', 'sea']) |
| 1897 | t2.validate() |
| 1898 | assert t2.column_names == ['eh', 'bee', 'sea'] |
| 1899 | assert t2.equals(expected) |
| 1900 | |
| 1901 | # Testing with tuple |
| 1902 | t3 = table.rename_columns(('eh', 'bee', 'sea')) |
| 1903 | t3.validate() |
| 1904 | assert t3.column_names == ['eh', 'bee', 'sea'] |
| 1905 | assert t3.equals(expected) |
| 1906 | |
| 1907 | message = "names must be a list or dict not <class 'str'>" |
| 1908 | with pytest.raises(TypeError, match=message): |
| 1909 | table.rename_columns('not a list') |
| 1910 | |
| 1911 | |
| 1912 | @pytest.mark.parametrize( |