Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
7a65c95d
Kaydet (Commit)
7a65c95d
authored
Haz 04, 2013
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactored file_storage tests to avoid depending on servers tests.
üst
96c71d42
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
7 deletions
+18
-7
tests.py
tests/file_storage/tests.py
+11
-7
urls.py
tests/file_storage/urls.py
+7
-0
No files found.
tests/file_storage/tests.py
Dosyayı görüntüle @
7a65c95d
...
@@ -7,6 +7,10 @@ import shutil
...
@@ -7,6 +7,10 @@ import shutil
import
sys
import
sys
import
tempfile
import
tempfile
import
time
import
time
try
:
from
urllib.request
import
urlopen
except
ImportError
:
# Python 2
from
urllib2
import
urlopen
import
zlib
import
zlib
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
io
import
BytesIO
from
io
import
BytesIO
...
@@ -22,12 +26,11 @@ from django.core.files.base import File, ContentFile
...
@@ -22,12 +26,11 @@ from django.core.files.base import File, ContentFile
from
django.core.files.images
import
get_image_dimensions
from
django.core.files.images
import
get_image_dimensions
from
django.core.files.storage
import
FileSystemStorage
,
get_storage_class
from
django.core.files.storage
import
FileSystemStorage
,
get_storage_class
from
django.core.files.uploadedfile
import
UploadedFile
from
django.core.files.uploadedfile
import
UploadedFile
from
django.test
import
SimpleTestCase
from
django.test
import
LiveServerTestCase
,
SimpleTestCase
from
django.utils
import
six
from
django.utils
import
six
from
django.utils
import
unittest
from
django.utils
import
unittest
from
django.utils._os
import
upath
from
django.utils._os
import
upath
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
servers.tests
import
LiveServerBase
try
:
try
:
from
django.utils.image
import
Image
from
django.utils.image
import
Image
...
@@ -613,10 +616,13 @@ class NoNameFileTestCase(unittest.TestCase):
...
@@ -613,10 +616,13 @@ class NoNameFileTestCase(unittest.TestCase):
def
test_noname_file_get_size
(
self
):
def
test_noname_file_get_size
(
self
):
self
.
assertEqual
(
File
(
BytesIO
(
b
'A file with no name'
))
.
size
,
19
)
self
.
assertEqual
(
File
(
BytesIO
(
b
'A file with no name'
))
.
size
,
19
)
class
FileLikeObjectTestCase
(
LiveServerBase
):
class
FileLikeObjectTestCase
(
LiveServerTestCase
):
"""
"""
Test file-like objects (#15644).
Test file-like objects (#15644).
"""
"""
urls
=
'file_storage.urls'
def
setUp
(
self
):
def
setUp
(
self
):
self
.
temp_dir
=
tempfile
.
mkdtemp
()
self
.
temp_dir
=
tempfile
.
mkdtemp
()
self
.
storage
=
FileSystemStorage
(
location
=
self
.
temp_dir
)
self
.
storage
=
FileSystemStorage
(
location
=
self
.
temp_dir
)
...
@@ -628,12 +634,10 @@ class FileLikeObjectTestCase(LiveServerBase):
...
@@ -628,12 +634,10 @@ class FileLikeObjectTestCase(LiveServerBase):
"""
"""
Test the File storage API with a file like object coming from urllib2.urlopen()
Test the File storage API with a file like object coming from urllib2.urlopen()
"""
"""
file_like_object
=
urlopen
(
self
.
live_server_url
+
'/'
)
file_like_object
=
self
.
urlopen
(
'/example_view/'
)
f
=
File
(
file_like_object
)
f
=
File
(
file_like_object
)
stored_filename
=
self
.
storage
.
save
(
"remote_file.html"
,
f
)
stored_filename
=
self
.
storage
.
save
(
"remote_file.html"
,
f
)
remote_file
=
self
.
urlopen
(
'/example_view/'
)
remote_file
=
urlopen
(
self
.
live_server_url
+
'/'
)
with
self
.
storage
.
open
(
stored_filename
)
as
stored_file
:
with
self
.
storage
.
open
(
stored_filename
)
as
stored_file
:
self
.
assertEqual
(
stored_file
.
read
(),
remote_file
.
read
())
self
.
assertEqual
(
stored_file
.
read
(),
remote_file
.
read
())
tests/file_storage/urls.py
0 → 100644
Dosyayı görüntüle @
7a65c95d
from
django.conf.urls
import
patterns
,
url
from
django.http
import
HttpResponse
urlpatterns
=
patterns
(
''
,
url
(
r'^$'
,
lambda
req
:
HttpResponse
(
'example view'
)),
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment