1
0
mirror of https://github.com/django/django.git synced 2025-07-05 10:19:20 +00:00

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
This commit is contained in:
Kevin Kubasik 2009-06-02 14:53:25 +00:00
parent 295beee70b
commit f0489dffb9
10 changed files with 567 additions and 318 deletions

File diff suppressed because it is too large Load Diff

View File

@ -143,7 +143,7 @@ class GoogleMap(object):
@property
def icons(self):
"Returns a sequence of GIcon objects in this map."
return [marker.icon for marker in self.markers if marker.icon]
return set([marker.icon for marker in self.markers if marker.icon])
class GoogleMapSet(GoogleMap):
@ -221,6 +221,6 @@ class GoogleMapSet(GoogleMap):
@property
def icons(self):
"Returns a sequence of all icons in each map of the set."
icons = []
for map in self.maps: icons.extend(map.icons)
icons = set()
for map in self.maps: icons |= map.icons
return icons

View File

@ -231,6 +231,14 @@ class GIcon(object):
self.iconanchor = iconanchor
self.infowindowanchor = infowindowanchor
def __cmp__(self, other):
return cmp(self.varname, other.varname)
def __hash__(self):
# XOR with hash of GIcon type so that hash('varname') won't
# equal hash(GIcon('varname')).
return hash(self.__class__) ^ hash(self.varname)
class GMarker(GOverlayBase):
"""
A Python wrapper for the Google GMarker object. For more information

View File

@ -192,7 +192,7 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
elif field_type is OFTDate:
yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])
else:
raise TypeError('Unknown field type %s in %s' % (fld_type, mfield))
raise TypeError('Unknown field type %s in %s' % (field_type, mfield))
# TODO: Autodetection of multigeometry types (see #7218).
gtype = layer.geom_type

View File

@ -689,7 +689,7 @@ class BaseQuery(object):
If 'with_aliases' is true, any column names that are duplicated
(without the table names) are given unique aliases. This is needed in
some cases to avoid ambiguitity with nested queries.
some cases to avoid ambiguity with nested queries.
"""
qn = self.quote_name_unless_alias
qn2 = self.connection.ops.quote_name
@ -2362,7 +2362,7 @@ class BaseQuery(object):
return cursor
if result_type == SINGLE:
if self.ordering_aliases:
return cursor.fetchone()[:-len(results.ordering_aliases)]
return cursor.fetchone()[:-len(self.ordering_aliases)]
return cursor.fetchone()
# The MULTI case.

View File

@ -584,7 +584,7 @@ class BaseModelFormSet(BaseFormSet):
else:
return ugettext("Please correct the duplicate data for %(field)s, "
"which must be unique.") % {
"field": get_text_list(unique_check, _("and")),
"field": get_text_list(unique_check, unicode(_("and"))),
}
def get_date_error_message(self, date_check):

View File

@ -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):

View File

@ -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):

View File

@ -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):
"""