Browse Source

Fix: Add a mark 'IS_TEST' to decide if we should load image-urls

pull/128/head
winkidney 6 years ago
parent
commit
ac469d47f9
4 changed files with 14 additions and 1 deletions
  1. +1
    -1
      django_images/urls.py
  2. +3
    -0
      manage.py
  3. +3
    -0
      pinry/settings/base.py
  4. +7
    -0
      pinry/urls.py

+ 1
- 1
django_images/urls.py View File

@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.conf.urls import url
from . import views from . import views


urlpatterns = [ urlpatterns = [


+ 3
- 0
manage.py View File

@@ -6,5 +6,8 @@ if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.development") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.development")


from django.core.management import execute_from_command_line 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) execute_from_command_line(sys.argv)

+ 3
- 0
pinry/settings/base.py View File

@@ -134,5 +134,8 @@ IMAGE_SIZES = {
'square': {'crop': True, 'size': [125, 125]}, 'square': {'crop': True, 'size': [125, 125]},
} }


# IS_TEST is a variable to mark if the test is running
IS_TEST = False

# User custom settings # User custom settings
IMAGE_AUTO_DELETE = True IMAGE_AUTO_DELETE = True

+ 7
- 0
pinry/urls.py View File

@@ -19,3 +19,10 @@ if settings.DEBUG:
urlpatterns += [ urlpatterns += [
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT, }), url(r'^media/(?P<path>.*)$', 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')),
]

Loading…
Cancel
Save