[PATCH 3/3] changelog: add __len__ method

Filippo Giunchedi filippo at esaurito.net
Tue Aug 11 19:09:46 UTC 2009


Plus the trivial test, just because TDD is good
---
 debian_bundle/changelog.py |    3 +++
 tests/test_changelog.py    |    4 ++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/debian_bundle/changelog.py b/debian_bundle/changelog.py
index 7f03dc4..e64cc3c 100644
--- a/debian_bundle/changelog.py
+++ b/debian_bundle/changelog.py
@@ -497,6 +497,9 @@ class Changelog(object):
     def __iter__(self):
         return iter(self._blocks)
 
+    def __len__(self):
+        return len(self._blocks)
+
     def set_distributions(self, distributions):
         self._blocks[0].distributions = distributions
     distributions = property(lambda self: self._blocks[0].distributions,
diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index d8fb037..9c4bdd5 100755
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -163,6 +163,10 @@ class ChangelogTests(unittest.TestCase):
         c = changelog.Changelog(open('test_changelog'))
         self.assertEqual(map(str, c._blocks), map(str, c))
 
+    def test_len(self):
+        c = changelog.Changelog(open('test_changelog'))
+        self.assertEqual(len(c._blocks), len(c))
+
 class VersionTests(unittest.TestCase):
 
     def _test_version(self, full_version, epoch, upstream, debian):
-- 
1.6.3.3




More information about the pkg-python-debian-discuss mailing list