Skip to content

Commit 49c3ecc

Browse files
Add fast regressions for multiline CSV detection ranges
Signed-off-by: Ali Zulfiqar <codewithfourtix@gmail.com>
1 parent 0c94bb9 commit 49c3ecc

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/formattedcode/test_output_csv.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,29 @@ def test_flatten_scan_minimal():
9797
check_json(result, expected_file, regen=REGEN_TEST_FIXTURES)
9898

9999

100+
@pytest.mark.parametrize('group,key', [
101+
('copyrights', 'copyright'),
102+
('holders', 'holder'),
103+
('authors', 'author'),
104+
])
105+
def test_flatten_scan_preserves_multiline_detection_ranges(group, key):
106+
scan = [{
107+
'path': 'example.py',
108+
group: [{key: 'Example', 'start_line': 10, 'end_line': 13}],
109+
}]
110+
headers = {name: [] for name in ('info', 'license', 'copyright', 'email', 'url', 'package')}
111+
112+
rows = list(flatten_scan(scan, headers))
113+
114+
assert rows[1] == {
115+
'path': 'example.py',
116+
key: 'Example',
117+
'start_line': 10,
118+
'end_line': 13,
119+
}
120+
assert headers['copyright'] == [key, 'start_line', 'end_line']
121+
122+
100123
def test_flatten_scan_can_process_path_with_and_without_leading_slash():
101124
test_json = test_env.get_test_loc('csv/flatten_scan/path_with_and_without_leading_slash.json')
102125
scan = load_scan(test_json)

0 commit comments

Comments
 (0)