Skip to content

Commit

Permalink
Reverted "Fixed #26644 -- Allowed wrapping NamedTemporaryFile with Fi…
Browse files Browse the repository at this point in the history
…le."

This reverts commit 1b40705 as it
introduces a regression in the test for refs #26772.
  • Loading branch information
timgraham committed Jun 18, 2016
1 parent 625b8e9 commit cd217de
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 18 deletions.
4 changes: 0 additions & 4 deletions django/core/files/base.py
Expand Up @@ -18,10 +18,6 @@ def __init__(self, file, name=None):
self.file = file
if name is None:
name = getattr(file, 'name', None)
# Use only the basename from a file's name if it's an absolute path,
# e.g. from NamedTemporaryFile.
if isinstance(name, six.string_types) and os.path.isabs(name):
name = os.path.basename(name)
self.name = name
if hasattr(file, 'mode'):
self.mode = file.mode
Expand Down
8 changes: 0 additions & 8 deletions tests/file_storage/tests.py
Expand Up @@ -10,7 +10,6 @@
import time
import unittest
from datetime import datetime, timedelta
from tempfile import NamedTemporaryFile

from django.core.cache import cache
from django.core.exceptions import SuspiciousFileOperation, SuspiciousOperation
Expand Down Expand Up @@ -860,13 +859,6 @@ def test_stringio(self):
with temp_storage.open('tests/stringio') as f:
self.assertEqual(f.read(), b'content')

def test_save_temporary_file(self):
storage = Storage()
with NamedTemporaryFile() as f:
f.write(b'content')
storage.normal = File(f)
storage.save() # no crash


# Tests for a race condition on file saving (#4948).
# This is written in such a way that it'll always pass on platforms
Expand Down
6 changes: 0 additions & 6 deletions tests/files/tests.py
Expand Up @@ -26,12 +26,6 @@


class FileTests(unittest.TestCase):

def test_file_truncates_namedtemporaryfile_name(self):
named_file = NamedTemporaryFile()
f = File(named_file)
self.assertEqual(f.name, os.path.basename(named_file.name))

def test_unicode_uploadedfile_name(self):
uf = UploadedFile(name='¿Cómo?', content_type='text')
self.assertIs(type(repr(uf)), str)
Expand Down

0 comments on commit cd217de

Please sign in to comment.