aboutsummaryrefslogtreecommitdiffstats
path: root/unittest/notifying_list.py
diff options
context:
space:
mode:
authorOlivier Tilloy <olivier@tilloy.net>2009-04-28 20:00:10 +0200
committerOlivier Tilloy <olivier@tilloy.net>2009-04-28 20:00:10 +0200
commit6a0980ac1cb704dd115748c808d7a9e4aa1fd05a (patch)
tree911deeea3d3ec60806492385e9e80f8d18137e21 /unittest/notifying_list.py
parent2ef70464cbfeead5795a46ba2354b7b5b1c3780c (diff)
downloadpyexiv2-6a0980ac1cb704dd115748c808d7a9e4aa1fd05a.tar.gz
Notify on insert().
Diffstat (limited to 'unittest/notifying_list.py')
-rw-r--r--unittest/notifying_list.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/unittest/notifying_list.py b/unittest/notifying_list.py
index 1834626..862f45a 100644
--- a/unittest/notifying_list.py
+++ b/unittest/notifying_list.py
@@ -52,6 +52,9 @@ class SimpleListener(ListenerInterface):
def extended(self, items):
self._notify('extended', items)
+ def item_inserted(self, index, item):
+ self._notify('item_inserted', index, item)
+
class TestNotifyingList(unittest.TestCase):
@@ -69,6 +72,7 @@ class TestNotifyingList(unittest.TestCase):
self.failUnlessRaises(NotImplementedError, self.values.__delitem__, 5)
self.failUnlessRaises(NotImplementedError, self.values.append, 17)
self.failUnlessRaises(NotImplementedError, self.values.extend, [11, 22])
+ self.failUnlessRaises(NotImplementedError, self.values.insert, 4, 24)
# TODO: test all operations (insertion, slicing, ...)
def test_one_listener(self):
@@ -86,7 +90,10 @@ class TestNotifyingList(unittest.TestCase):
self.values.extend([11, 22])
self.failUnlessEqual(listener.notifications, 4)
self.failUnlessEqual(listener.last, ('extended', ([11, 22],)))
- # TODO: test all operations (insertion, slicing, ...)
+ self.values.insert(4, 24)
+ self.failUnlessEqual(listener.notifications, 5)
+ self.failUnlessEqual(listener.last, ('item_inserted', (4, 24)))
+ # TODO: test all operations (slicing, ...)
def test_multiple_listeners(self):
# Register a random number of listeners
@@ -109,4 +116,8 @@ class TestNotifyingList(unittest.TestCase):
for listener in listeners:
self.failUnlessEqual(listener.notifications, 4)
self.failUnlessEqual(listener.last, ('extended', ([11, 22],)))
- # TODO: test all operations (insertion, slicing, ...)
+ self.values.insert(4, 24)
+ for listener in listeners:
+ self.failUnlessEqual(listener.notifications, 5)
+ self.failUnlessEqual(listener.last, ('item_inserted', (4, 24)))
+ # TODO: test all operations (slicing, ...)