Add file deletion capability and tests
This commit is contained in:
parent
32007d5c36
commit
e2698281c4
14
src/maildirclean/filedir.py
Normal file
14
src/maildirclean/filedir.py
Normal 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
10
tests/test_filedir.py
Normal 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()
|
Loading…
x
Reference in New Issue
Block a user