Running Django tests without collect static

Viewed 109

I am trying to run a test suite for django that uses inlinecss. inlinecss references a static file in the template as follows:

{% load inlinecss %}
{% inlinecss "css/emails/base.css" %}

When running in Debug mode this works fine, when running in production (having run collectstatic) this also works fine.

However when running tests (without running collectstatic before) I get the following:

FileNotFoundError: [Errno 2] No such file or directory: '/app/project-name/staticfiles/css/emails/base.css'

This makes sense as django is looking for the file in STATIC_ROOT (STATIC_ROOT = os.path.normpath(join(os.path.dirname(BASE_DIR), "staticfiles")))

I am wondering if there is a way to allow Django to access this file without having to run collectstatic? It would be ideal if I could add some settings to test.py so that it could collectstatic to a tmp directory or not require collectstatic at all (like when running in debug mode) but I have had no success trying this. I am using pytest to run tests.

0 Answers
Related