diff --git a/django_images/urls.py b/django_images/urls.py index 62cabcf..f3797c8 100644 --- a/django_images/urls.py +++ b/django_images/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import include, url +from django.conf.urls import url from . import views urlpatterns = [ diff --git a/manage.py b/manage.py index 77c2b5a..87a5565 100644 --- a/manage.py +++ b/manage.py @@ -6,5 +6,8 @@ if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.development") from django.core.management import execute_from_command_line + if 'test' in sys.argv: + from django.conf import settings + settings.IS_TEST = True execute_from_command_line(sys.argv) diff --git a/pinry/settings/base.py b/pinry/settings/base.py index e90825a..7191b1c 100644 --- a/pinry/settings/base.py +++ b/pinry/settings/base.py @@ -134,5 +134,8 @@ IMAGE_SIZES = { 'square': {'crop': True, 'size': [125, 125]}, } +# IS_TEST is a variable to mark if the test is running +IS_TEST = False + # User custom settings IMAGE_AUTO_DELETE = True diff --git a/pinry/urls.py b/pinry/urls.py index dd1bceb..1311a18 100644 --- a/pinry/urls.py +++ b/pinry/urls.py @@ -19,3 +19,10 @@ if settings.DEBUG: urlpatterns += [ url(r'^media/(?P.*)$', serve, {'document_root': settings.MEDIA_ROOT, }), ] + +if settings.IS_TEST: + urlpatterns += staticfiles_urlpatterns() + # For test running of django_images + urlpatterns += [ + url(r'^__images/', include('django_images.urls')), + ]