Add file deletion capability and tests

This commit is contained in:
Alex Selimov 2025-04-21 22:04:08 -04:00
parent 32007d5c36
commit e2698281c4
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,14 @@
"""Module containing functionality to interact with the filesystem"""
import os
from pathlib import Path
def delete_files(file_list: list[str | Path]):
"""Delete all files in the provided file list
Args:
file_list: List of file paths as either strings or Path
"""
for file in file_list:
os.remove(file)

10
tests/test_filedir.py Normal file
View File

@ -0,0 +1,10 @@
from fixtures import *
from maildirclean.filedir import delete_files
def test_delete_files(sample_email_dir):
file_list = list(Path(sample_email_dir).glob("*"))
delete_files(file_list)
for file in file_list:
assert not Path(file).is_file()