Commits

jfunk  committed a10a8ad

Add __len__() method to Choices

  • Participants
  • Parent commits 730c25f

Comments (0)

Files changed (2)

File model_utils/__init__.py

             else:
                 yield (choice, choice, choice)
 
+    def __len__(self):
+        return len(self._choices)
+
     def __iter__(self):
         return iter(self._choices)
 

File model_utils/tests/tests.py

     def test_wrong_length_tuple(self):
         self.assertRaises(ValueError, Choices, ('a',))
 
+    def test_len(self):
+        self.assertEquals(len(self.STATUS), len(self.STATUS._choices))
+
 
 
 class LabelChoicesTests(ChoicesTests):