Kaydet (Commit) f675afa1 authored tarafından darkryder's avatar darkryder Kaydeden (comit) Tim Graham

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

üst 11e6bf9b
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment