summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Kubasik <kevin@kubasik.net>2009-06-02 14:53:25 +0000
committerKevin Kubasik <kevin@kubasik.net>2009-06-02 14:53:25 +0000
commitf0489dffb93f82ca21251a67d85124df615f652d (patch)
tree995a38edca8c683f8bad4ba179814ce19de76386 /tests
parent295beee70b5144983f120f7376cfbf4504a771a5 (diff)
Merge branch 'master' into local/gsoc
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/test-improvements@10890 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_scripts/tests.py2
-rw-r--r--tests/regressiontests/file_storage/tests.py12
-rw-r--r--tests/regressiontests/model_fields/imagefield.py17
3 files changed, 24 insertions, 7 deletions
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index 0e28a9749f..e67126e9a7 100644
--- a/tests/regressiontests/admin_scripts/tests.py
+++ b/tests/regressiontests/admin_scripts/tests.py
@@ -536,7 +536,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
args = ['startapp','settings_test']
out, err = self.run_django_admin(args,'settings')
self.assertNoOutput(err)
- self.assertTrue(os.path.exists(os.path.join(test_dir, 'settings_test')))
+ self.assert_(os.path.exists(os.path.join(test_dir, 'settings_test')))
shutil.rmtree(os.path.join(test_dir, 'settings_test'))
def test_builtin_command(self):
diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
index 6e2b7be8e7..c228764e06 100644
--- a/tests/regressiontests/file_storage/tests.py
+++ b/tests/regressiontests/file_storage/tests.py
@@ -161,9 +161,9 @@ class FileStoragePathParsing(TestCase):
self.storage.save('dotted.path/test', ContentFile("1"))
self.storage.save('dotted.path/test', ContentFile("2"))
- self.assertFalse(os.path.exists(os.path.join(self.storage_dir, 'dotted_.path')))
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test')))
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test_')))
+ self.failIf(os.path.exists(os.path.join(self.storage_dir, 'dotted_.path')))
+ self.assert_(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test')))
+ self.assert_(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test_')))
def test_first_character_dot(self):
"""
@@ -173,13 +173,13 @@ class FileStoragePathParsing(TestCase):
self.storage.save('dotted.path/.test', ContentFile("1"))
self.storage.save('dotted.path/.test', ContentFile("2"))
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test')))
+ self.assert_(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test')))
# Before 2.6, a leading dot was treated as an extension, and so
# underscore gets added to beginning instead of end.
if sys.version_info < (2, 6):
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/_.test')))
+ self.assert_(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/_.test')))
else:
- self.assertTrue(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test_')))
+ self.assert_(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/.test_')))
if Image is not None:
class DimensionClosingBug(TestCase):
diff --git a/tests/regressiontests/model_fields/imagefield.py b/tests/regressiontests/model_fields/imagefield.py
index 09bda6bb2d..dd79e7aefa 100644
--- a/tests/regressiontests/model_fields/imagefield.py
+++ b/tests/regressiontests/model_fields/imagefield.py
@@ -150,6 +150,23 @@ if Image:
_ = p.mugshot.size
self.assertEqual(p.mugshot.closed, True)
+ def test_pickle(self):
+ """
+ Tests that ImageField can be pickled, unpickled, and that the
+ image of the unpickled version is the same as the original.
+ """
+ import pickle
+
+ p = Person(name="Joe")
+ p.mugshot.save("mug", self.file1)
+ dump = pickle.dumps(p)
+
+ p2 = Person(name="Bob")
+ p2.mugshot = self.file1
+
+ loaded_p = pickle.loads(dump)
+ self.assertEqual(p.mugshot, loaded_p.mugshot)
+
class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
"""