Browse Source

Prevent duplicates in LimitedSet

Dave Smith 9 years ago
parent
commit
933d57d413
1 changed files with 7 additions and 0 deletions
  1. 7 0
      celery/tests/utils/test_datastructures.py

+ 7 - 0
celery/tests/utils/test_datastructures.py

@@ -337,6 +337,13 @@ class test_LimitedSet(Case):
         s.add('foo')
         s.add('foo')
         self.assertIsInstance(s.as_dict(), Mapping)
         self.assertIsInstance(s.as_dict(), Mapping)
 
 
+    def test_no_duplicates(self):
+        s = LimitedSet(maxlen=2)
+        s.add('foo')
+        s.add('foo')
+        self.assertEqual(len(s), 1)
+        self.assertEqual(len(s._data), 1)
+        self.assertEqual(len(s._heap), 1)
 
 
 class test_AttributeDict(Case):
 class test_AttributeDict(Case):