|
2 | 2 | # functions, not the general printing of pandas objects.
|
3 | 3 | from collections.abc import Mapping
|
4 | 4 | import string
|
| 5 | + |
5 | 6 | import pytest
|
| 7 | + |
6 | 8 | import pandas._config.config as cf
|
| 9 | + |
7 | 10 | import pandas as pd
|
| 11 | + |
8 | 12 | from pandas.io.formats import printing
|
9 | 13 |
|
10 | 14 |
|
11 |
| -@pytest.mark.parametrize("input_names, expected_names", [ |
12 |
| - (["'a", "b"], ["\'a", "b"]), # Escape leading quote |
13 |
| - (["test's", "b"], ["test\'s", "b"]), # Escape apostrophe |
14 |
| - (["'test'", "b"], ["\'test\'", "b"]), # Escape surrounding quotes |
15 |
| - (["test","b'"], ["test","b\'"]), # Escape single quote |
16 |
| - (["'test\n'", "b"], ["\'test\n\'", "b"]) # Escape and preserve newline |
17 |
| -]) |
| 15 | +@pytest.mark.parametrize( |
| 16 | + "input_names, expected_names", |
| 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 |
| 23 | + ], |
| 24 | +) |
18 | 25 | def test_formatted_index_names(input_names, expected_names):
|
19 |
| - # Create DataFrame with specified index names |
20 |
| - df = pd.DataFrame( |
21 |
| - {name: [1, 2, 3] for name in input_names} |
22 |
| - ).set_index(input_names) |
| 26 | + # GH#60190 |
| 27 | + df = pd.DataFrame({name: [1, 2, 3] for name in input_names}).set_index(input_names) |
23 | 28 | formatted_names = df.index.names
|
24 |
| - |
| 29 | + |
25 | 30 | assert formatted_names == expected_names
|
26 | 31 |
|
27 | 32 |
|
|
0 commit comments