mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #4040 -- Changed uses of has_key() to "in". Slight performance
improvement and forward-compatible with future Python releases. Patch from Gary Wilson. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5091 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -55,8 +55,10 @@ class Tester(unittest.TestCase):
|
||||
for t in self.ts:
|
||||
if hasattr(t, 'x'):
|
||||
self.assert_(sd.has_key(safeRef(t.x)))
|
||||
self.assert_(safeRef(t.x) in sd)
|
||||
else:
|
||||
self.assert_(sd.has_key(safeRef(t)))
|
||||
self.assert_(safeRef(t) in sd)
|
||||
|
||||
def testRepresentation (self):
|
||||
"""Test that the reference object's representation works
|
||||
|
||||
@@ -34,6 +34,9 @@ AttributeError: This QueryDict instance is immutable
|
||||
>>> q.has_key('foo')
|
||||
False
|
||||
|
||||
>>> 'foo' in q
|
||||
False
|
||||
|
||||
>>> q.items()
|
||||
[]
|
||||
|
||||
@@ -124,6 +127,9 @@ MultiValueDictKeyError: "Key 'foo' not found in <MultiValueDict: {}>"
|
||||
>>> q.has_key('foo')
|
||||
True
|
||||
|
||||
>>> 'foo' in q
|
||||
True
|
||||
|
||||
>>> q.items()
|
||||
[('foo', 'another'), ('name', 'john')]
|
||||
|
||||
@@ -218,9 +224,15 @@ AttributeError: This QueryDict instance is immutable
|
||||
>>> q.has_key('foo')
|
||||
True
|
||||
|
||||
>>> 'foo' in q
|
||||
True
|
||||
|
||||
>>> q.has_key('bar')
|
||||
False
|
||||
|
||||
>>> 'bar' in q
|
||||
False
|
||||
|
||||
>>> q.items()
|
||||
[('foo', 'bar')]
|
||||
|
||||
@@ -303,9 +315,15 @@ AttributeError: This QueryDict instance is immutable
|
||||
>>> q.has_key('vote')
|
||||
True
|
||||
|
||||
>>> 'vote' in q
|
||||
True
|
||||
|
||||
>>> q.has_key('foo')
|
||||
False
|
||||
|
||||
>>> 'foo' in q
|
||||
False
|
||||
|
||||
>>> q.items()
|
||||
[('vote', 'no')]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user