mirror of https://github.com/django/django.git
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
|
def __nonzero__(self): # Python 2 compatibility
|
||||||
return type(self).__bool__(self)
|
return type(self).__bool__(self)
|
||||||
|
|
||||||
|
def __len__(self):
|
||||||
|
return len(self.dict)
|
||||||
|
|
||||||
|
|
||||||
class MultiValueDictKeyError(KeyError):
|
class MultiValueDictKeyError(KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -21,6 +21,14 @@ class OrderedSetTests(SimpleTestCase):
|
||||||
s.add(1)
|
s.add(1)
|
||||||
self.assertTrue(s)
|
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):
|
class MultiValueDictTests(SimpleTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue