mirror of
https://github.com/django/django.git
synced 2024-12-23 01:25:58 +00:00
Fixed #25093 -- Added utils.datastructures.OrderedSet.__len__()
This commit is contained in:
parent
11e6bf9bdf
commit
f675afa13c
@ -37,6 +37,9 @@ class OrderedSet(object):
|
||||
def __nonzero__(self): # Python 2 compatibility
|
||||
return type(self).__bool__(self)
|
||||
|
||||
def __len__(self):
|
||||
return len(self.dict)
|
||||
|
||||
|
||||
class MultiValueDictKeyError(KeyError):
|
||||
pass
|
||||
|
@ -21,6 +21,14 @@ class OrderedSetTests(SimpleTestCase):
|
||||
s.add(1)
|
||||
self.assertTrue(s)
|
||||
|
||||
def test_len(self):
|
||||
s = OrderedSet()
|
||||
self.assertEqual(len(s), 0)
|
||||
s.add(1)
|
||||
s.add(2)
|
||||
s.add(2)
|
||||
self.assertEqual(len(s), 2)
|
||||
|
||||
|
||||
class MultiValueDictTests(SimpleTestCase):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user