mirror of
https://github.com/Hopiu/django-model-utils.git
synced 2026-04-22 12:04:43 +00:00
Merged in jfunk/django-model-utils (pull request #9)
Add __len__() method to Choices
This commit is contained in:
commit
6935f73233
2 changed files with 6 additions and 0 deletions
|
|
@ -118,6 +118,9 @@ class Choices(object):
|
|||
else:
|
||||
yield (choice, choice, choice)
|
||||
|
||||
def __len__(self):
|
||||
return len(self._choices)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self._choices)
|
||||
|
||||
|
|
|
|||
|
|
@ -193,6 +193,9 @@ class ChoicesTests(TestCase):
|
|||
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):
|
||||
|
|
|
|||
Loading…
Reference in a new issue