๐ Easily create temporary folders, add files into them and don't worry about deleting them, tempfolder will take care
Documentation: https://jalvaradosegura.github.io/tempfolder/
tempfolder is published on PyPI and can be installed from there:
pip install tempfolder
For a deeper explanation, please check the docs...
Run this and see if you spot the magic, if you don't, please check the docs:
from pathlib import Path
from tempfolder import use_temp_folder
def add_config_file_to_folder(folder: str):
with open(f'{folder}/config.cfg', 'w') as f:
f.write('I_love=tempfolder')
@use_temp_folder('some_folder')
def test_add_config_file_to_folder():
add_config_file_to_folder('some_folder')
assert Path('some_folder').exists()
assert Path('some_folder/config.cfg').exists()
def test_look_for_the_folder_and_the_file():
assert not Path('some_folder').exists()
assert not Path('some_folder/config.cfg').exists()
test_add_config_file_to_folder()
test_look_for_the_folder_and_the_file()