Scrub windows paths for invalid characters

This commit is contained in:
Serene-Arc
2021-03-22 14:21:56 +10:00
committed by Ali Parlakci
parent b3c51f49ce
commit 0007912ad5
2 changed files with 27 additions and 1 deletions

View File

@@ -169,3 +169,16 @@ def test_shorten_filenames(reddit_instance: praw.Reddit, tmp_path: Path):
result = test_formatter.format_path(test_resource, tmp_path)
result.parent.mkdir(parents=True)
result.touch()
@pytest.mark.parametrize(('test_string', 'expected'), (
('test', 'test'),
('test.png', 'test.png'),
('test*', 'test'),
('test**', 'test'),
('test?*', 'test'),
('test_???.png', 'test_.png'),
))
def test_format_file_name_for_windows(test_string: str, expected: str):
result = FileNameFormatter._format_for_windows(test_string)
assert result == expected