I'm making a Flask REST API with Flask-RESTX library. One part of API are also calls that generate PDF documents. To generate documents I'm using some font files and images from the static/
directory. Everything is working when I'm running the API, but when I'm trying to call the same calls from my tests I'm getting an error that files used in PDF generation can't be found.
OSError: Cannot open resource "static/logo.png"
I'm guessing the reason for this is that the path to static
folder is different when running tests. Is there a nice way to use the same path to static files in tests or there needs to be some custom path-switching logic depending on the run type (development, production, testing).
Folder structure:
/src
/application
/main
app.py
/test
test.py
/static
logo.png
I access the assets in my application as such:
static/logo.png