Unit Test: How To Mock MEDIA_ROOT But Still Access A File That Is Stored In My Normal MEDIA Folder
The problem:
PDF files are building up in your MEDIA_ROOT folder because there is nothing automatically deleting them.
Recommended solution:
I actually ran into this problem a few months ago myself, and the solution I found was the django-cleanup tool. It's very easy to install and integrate into your app (simply add it to your INSTALLED_APPS
in settings.py
).
Note: This is assuming that your PDF files are in a FileField
of one of your models. If that's not the case, then this solution won't work for you.