Fixed #25093 -- Added utils.datastructures.OrderedSet.__len__()

This commit is contained in:
darkryder 2015-07-09 23:30:36 +05:30 committed by Tim Graham
parent 11e6bf9bdf
commit f675afa13c
2 changed files with 11 additions and 0 deletions

View File

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

View File

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