Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
b1316509
Commit
b1316509
authored
Jul 28, 2013
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed python3 tests
parent
e480f5df
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
7 deletions
+10
-7
upload.py
flask_admin/form/upload.py
+1
-1
test_form_upload.py
flask_admin/tests/test_form_upload.py
+9
-6
No files found.
flask_admin/form/upload.py
View file @
b1316509
...
@@ -322,7 +322,7 @@ class ImageUploadField(FileUploadField):
...
@@ -322,7 +322,7 @@ class ImageUploadField(FileUploadField):
thumb
=
self
.
image
.
copy
()
.
thumbnail
((
width
,
height
),
Image
.
ANTIALIAS
)
thumb
=
self
.
image
.
copy
()
.
thumbnail
((
width
,
height
),
Image
.
ANTIALIAS
)
path
=
op
.
join
(
self
.
path
,
self
.
thumbnail_fn
(
filename
))
path
=
op
.
join
(
self
.
path
,
self
.
thumbnail_fn
(
filename
))
with
file
(
path
,
'wb'
)
as
fp
:
with
open
(
path
,
'wb'
)
as
fp
:
thumb
.
save
(
fp
,
'JPEG'
)
thumb
.
save
(
fp
,
'JPEG'
)
...
...
flask_admin/tests/test_form_upload.py
View file @
b1316509
import
os
import
os
import
os.path
as
op
import
os.path
as
op
from
StringIO
import
StringIO
from
io
import
BytesIO
from
nose.tools
import
eq_
,
ok_
from
nose.tools
import
eq_
,
ok_
...
@@ -45,7 +46,7 @@ def test_upload_field():
...
@@ -45,7 +46,7 @@ def test_upload_field():
dummy
=
Dummy
()
dummy
=
Dummy
()
# Check upload
# Check upload
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
StringIO
(
'Hello World
'
),
'test1.txt'
)}):
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
BytesIO
(
b
'Hello World 1
'
),
'test1.txt'
)}):
my_form
=
TestForm
(
helpers
.
get_form_data
())
my_form
=
TestForm
(
helpers
.
get_form_data
())
ok_
(
my_form
.
validate
())
ok_
(
my_form
.
validate
())
...
@@ -56,7 +57,7 @@ def test_upload_field():
...
@@ -56,7 +57,7 @@ def test_upload_field():
ok_
(
op
.
exists
(
op
.
join
(
path
,
'test1.txt'
)))
ok_
(
op
.
exists
(
op
.
join
(
path
,
'test1.txt'
)))
# Check replace
# Check replace
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
StringIO
(
'Hello World
'
),
'test2.txt'
)}):
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
BytesIO
(
b
'Hello World 2
'
),
'test2.txt'
)}):
my_form
=
TestForm
(
helpers
.
get_form_data
())
my_form
=
TestForm
(
helpers
.
get_form_data
())
ok_
(
my_form
.
validate
())
ok_
(
my_form
.
validate
())
...
@@ -107,7 +108,9 @@ def test_image_upload_field():
...
@@ -107,7 +108,9 @@ def test_image_upload_field():
dummy
=
Dummy
()
dummy
=
Dummy
()
# Check upload
# Check upload
with
file
(
op
.
join
(
op
.
dirname
(
__file__
),
'data'
,
'copyleft.png'
),
'rb'
)
as
fp
:
filename
=
op
.
join
(
op
.
dirname
(
__file__
),
'data'
,
'copyleft.png'
)
with
open
(
filename
,
'rb'
)
as
fp
:
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
fp
,
'test1.png'
)}):
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
fp
,
'test1.png'
)}):
my_form
=
TestForm
(
helpers
.
get_form_data
())
my_form
=
TestForm
(
helpers
.
get_form_data
())
...
@@ -120,7 +123,7 @@ def test_image_upload_field():
...
@@ -120,7 +123,7 @@ def test_image_upload_field():
ok_
(
op
.
exists
(
op
.
join
(
path
,
'test1_thumb.jpg'
)))
ok_
(
op
.
exists
(
op
.
join
(
path
,
'test1_thumb.jpg'
)))
# Check replace
# Check replace
with
file
(
op
.
join
(
op
.
dirname
(
__file__
),
'data'
,
'copyleft.png'
)
,
'rb'
)
as
fp
:
with
open
(
filename
,
'rb'
)
as
fp
:
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
fp
,
'test2.png'
)}):
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
fp
,
'test2.png'
)}):
my_form
=
TestForm
(
helpers
.
get_form_data
())
my_form
=
TestForm
(
helpers
.
get_form_data
())
...
@@ -148,7 +151,7 @@ def test_image_upload_field():
...
@@ -148,7 +151,7 @@ def test_image_upload_field():
ok_
(
not
op
.
exists
(
op
.
join
(
path
,
'test2_thumb.jpg'
)))
ok_
(
not
op
.
exists
(
op
.
join
(
path
,
'test2_thumb.jpg'
)))
# Check upload no-resize
# Check upload no-resize
with
file
(
op
.
join
(
op
.
dirname
(
__file__
),
'data'
,
'copyleft.png'
)
,
'rb'
)
as
fp
:
with
open
(
filename
,
'rb'
)
as
fp
:
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
fp
,
'test1.png'
)}):
with
app
.
test_request_context
(
method
=
'POST'
,
data
=
{
'upload'
:
(
fp
,
'test1.png'
)}):
my_form
=
TestNoResizeForm
(
helpers
.
get_form_data
())
my_form
=
TestNoResizeForm
(
helpers
.
get_form_data
())
...
...
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