mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #19215 -- Fixed admin_widgets tests if Pillow isn't installed.
Follow up to c0fc1b5302
.
This commit is contained in:
parent
eb6cc01d0f
commit
d559cb02da
@ -5,8 +5,13 @@ from django.contrib.auth.models import User
|
|||||||
from django.core.files.storage import FileSystemStorage
|
from django.core.files.storage import FileSystemStorage
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
temp_storage_dir = tempfile.mkdtemp()
|
try:
|
||||||
temp_storage = FileSystemStorage(temp_storage_dir)
|
from PIL import Image
|
||||||
|
except ImportError:
|
||||||
|
Image = None
|
||||||
|
else:
|
||||||
|
temp_storage_dir = tempfile.mkdtemp()
|
||||||
|
temp_storage = FileSystemStorage(temp_storage_dir)
|
||||||
|
|
||||||
|
|
||||||
class MyFileField(models.FileField):
|
class MyFileField(models.FileField):
|
||||||
@ -182,9 +187,10 @@ class Advisor(models.Model):
|
|||||||
|
|
||||||
class Student(models.Model):
|
class Student(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
photo = models.ImageField(
|
if Image:
|
||||||
storage=temp_storage, upload_to="photos", blank=True, null=True
|
photo = models.ImageField(
|
||||||
)
|
storage=temp_storage, upload_to="photos", blank=True, null=True
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ("name",)
|
ordering = ("name",)
|
||||||
|
@ -3,6 +3,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
|
from unittest import skipUnless
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import zoneinfo
|
import zoneinfo
|
||||||
@ -38,6 +39,7 @@ from .models import (
|
|||||||
Company,
|
Company,
|
||||||
Event,
|
Event,
|
||||||
Honeycomb,
|
Honeycomb,
|
||||||
|
Image,
|
||||||
Individual,
|
Individual,
|
||||||
Inventory,
|
Inventory,
|
||||||
Member,
|
Member,
|
||||||
@ -1774,6 +1776,7 @@ class RelatedFieldWidgetSeleniumTests(AdminWidgetSeleniumTestCase):
|
|||||||
self.assertEqual(profiles[0].user.username, username_value)
|
self.assertEqual(profiles[0].user.username, username_value)
|
||||||
|
|
||||||
|
|
||||||
|
@skipUnless(Image, "Pillow not installed")
|
||||||
class ImageFieldWidgetsSeleniumTests(AdminWidgetSeleniumTestCase):
|
class ImageFieldWidgetsSeleniumTests(AdminWidgetSeleniumTestCase):
|
||||||
def test_clearablefileinput_widget(self):
|
def test_clearablefileinput_widget(self):
|
||||||
from selenium.webdriver.common.by import By
|
from selenium.webdriver.common.by import By
|
||||||
|
Loading…
Reference in New Issue
Block a user