|
15 | 15 | @pytest.mark.parametrize(
|
16 | 16 | "input_names, expected_names",
|
17 | 17 | [
|
18 |
| - (["'a", "b"], ["'a", "b"]), # Escape leading quote |
19 |
| - (["test's", "b"], ["test's", "b"]), # Escape apostrophe |
20 |
| - (["'test'", "b"], ["'test'", "b"]), # Escape surrounding quotes |
21 |
| - (["test", "b'"], ["test", "b'"]), # Escape single quote |
22 |
| - (["'test\n'", "b"], ["'test\n'", "b"]), # Escape and preserve newline |
| 18 | + (["'a b"], "['\\'a b']"), # Escape leading quote |
| 19 | + (["test's b"], "['test\\'s b']"), # Escape apostrophe |
| 20 | + (["'test' b"], "['\\'test\\' b']"), # Escape surrounding quotes |
| 21 | + (["test b'"], "['test b\\'']"), # Escape single quote |
| 22 | + (["test\n' b"], "['test\\n\\' b']"), # Escape quotes, preserve newline |
23 | 23 | ],
|
24 | 24 | )
|
25 | 25 | def test_formatted_index_names(input_names, expected_names):
|
26 | 26 | # GH#60190
|
27 | 27 | df = pd.DataFrame({name: [1, 2, 3] for name in input_names}).set_index(input_names)
|
28 |
| - formatted_names = df.index.names |
| 28 | + formatted_names = str(df.index.names) |
29 | 29 |
|
30 | 30 | assert formatted_names == expected_names
|
31 | 31 |
|
|
0 commit comments