mirror of
https://github.com/django/django.git
synced 2025-07-06 02:39:12 +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:
parent
295beee70b
commit
f0489dffb9
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -143,7 +143,7 @@ class GoogleMap(object):
|
|||||||
@property
|
@property
|
||||||
def icons(self):
|
def icons(self):
|
||||||
"Returns a sequence of GIcon objects in this map."
|
"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):
|
class GoogleMapSet(GoogleMap):
|
||||||
|
|
||||||
@ -221,6 +221,6 @@ class GoogleMapSet(GoogleMap):
|
|||||||
@property
|
@property
|
||||||
def icons(self):
|
def icons(self):
|
||||||
"Returns a sequence of all icons in each map of the set."
|
"Returns a sequence of all icons in each map of the set."
|
||||||
icons = []
|
icons = set()
|
||||||
for map in self.maps: icons.extend(map.icons)
|
for map in self.maps: icons |= map.icons
|
||||||
return icons
|
return icons
|
||||||
|
@ -231,6 +231,14 @@ class GIcon(object):
|
|||||||
self.iconanchor = iconanchor
|
self.iconanchor = iconanchor
|
||||||
self.infowindowanchor = infowindowanchor
|
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):
|
class GMarker(GOverlayBase):
|
||||||
"""
|
"""
|
||||||
A Python wrapper for the Google GMarker object. For more information
|
A Python wrapper for the Google GMarker object. For more information
|
||||||
|
@ -192,7 +192,7 @@ def _ogrinspect(data_source, model_name, geom_name='geom', layer_key=0, srid=Non
|
|||||||
elif field_type is OFTDate:
|
elif field_type is OFTDate:
|
||||||
yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])
|
yield ' %s = models.TimeField(%s)' % (mfield, kwargs_str[2:])
|
||||||
else:
|
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).
|
# TODO: Autodetection of multigeometry types (see #7218).
|
||||||
gtype = layer.geom_type
|
gtype = layer.geom_type
|
||||||
|
@ -689,7 +689,7 @@ class BaseQuery(object):
|
|||||||
|
|
||||||
If 'with_aliases' is true, any column names that are duplicated
|
If 'with_aliases' is true, any column names that are duplicated
|
||||||
(without the table names) are given unique aliases. This is needed in
|
(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
|
qn = self.quote_name_unless_alias
|
||||||
qn2 = self.connection.ops.quote_name
|
qn2 = self.connection.ops.quote_name
|
||||||
@ -2362,7 +2362,7 @@ class BaseQuery(object):
|
|||||||
return cursor
|
return cursor
|
||||||
if result_type == SINGLE:
|
if result_type == SINGLE:
|
||||||
if self.ordering_aliases:
|
if self.ordering_aliases:
|
||||||
return cursor.fetchone()[:-len(results.ordering_aliases)]
|
return cursor.fetchone()[:-len(self.ordering_aliases)]
|
||||||
return cursor.fetchone()
|
return cursor.fetchone()
|
||||||
|
|
||||||
# The MULTI case.
|
# The MULTI case.
|
||||||
|
@ -584,7 +584,7 @@ class BaseModelFormSet(BaseFormSet):
|
|||||||
else:
|
else:
|
||||||
return ugettext("Please correct the duplicate data for %(field)s, "
|
return ugettext("Please correct the duplicate data for %(field)s, "
|
||||||
"which must be unique.") % {
|
"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):
|
def get_date_error_message(self, date_check):
|
||||||
|
@ -536,7 +536,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
|
|||||||
args = ['startapp','settings_test']
|
args = ['startapp','settings_test']
|
||||||
out, err = self.run_django_admin(args,'settings')
|
out, err = self.run_django_admin(args,'settings')
|
||||||
self.assertNoOutput(err)
|
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'))
|
shutil.rmtree(os.path.join(test_dir, 'settings_test'))
|
||||||
|
|
||||||
def test_builtin_command(self):
|
def test_builtin_command(self):
|
||||||
|
@ -161,9 +161,9 @@ class FileStoragePathParsing(TestCase):
|
|||||||
self.storage.save('dotted.path/test', ContentFile("1"))
|
self.storage.save('dotted.path/test', ContentFile("1"))
|
||||||
self.storage.save('dotted.path/test', ContentFile("2"))
|
self.storage.save('dotted.path/test', ContentFile("2"))
|
||||||
|
|
||||||
self.assertFalse(os.path.exists(os.path.join(self.storage_dir, 'dotted_.path')))
|
self.failIf(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.assert_(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.assert_(os.path.exists(os.path.join(self.storage_dir, 'dotted.path/test_')))
|
||||||
|
|
||||||
def test_first_character_dot(self):
|
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("1"))
|
||||||
self.storage.save('dotted.path/.test', ContentFile("2"))
|
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
|
# Before 2.6, a leading dot was treated as an extension, and so
|
||||||
# underscore gets added to beginning instead of end.
|
# underscore gets added to beginning instead of end.
|
||||||
if sys.version_info < (2, 6):
|
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:
|
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:
|
if Image is not None:
|
||||||
class DimensionClosingBug(TestCase):
|
class DimensionClosingBug(TestCase):
|
||||||
|
@ -150,6 +150,23 @@ if Image:
|
|||||||
_ = p.mugshot.size
|
_ = p.mugshot.size
|
||||||
self.assertEqual(p.mugshot.closed, True)
|
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):
|
class ImageFieldTwoDimensionsTests(ImageFieldTestMixin, TestCase):
|
||||||
"""
|
"""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user