summaryrefslogtreecommitdiff
path: root/test/git/async/test_channel.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-06-12 11:19:18 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-06-12 11:19:29 +0200
commitbe8955a0fbb77d673587974b763f17c214904b57 (patch)
tree3e4cb96ca162c676692f72fc53dc6b1d8dc29e20 /test/git/async/test_channel.py
parenta28942bdf01f4ddb9d0b5a0489bd6f4e101dd775 (diff)
downloadgitpython-be8955a0fbb77d673587974b763f17c214904b57.tar.gz
Cleaned up channel design, Reader and Writer bases don't require a channel anymore, but are abstract.
Added IteratorReader, implementing the reader interface from an iterator. The implementation moved from the TaskIterator to the channel
Diffstat (limited to 'test/git/async/test_channel.py')
-rw-r--r--test/git/async/test_channel.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/test/git/async/test_channel.py b/test/git/async/test_channel.py
index a24c7c91..e9e1b64c 100644
--- a/test/git/async/test_channel.py
+++ b/test/git/async/test_channel.py
@@ -9,8 +9,8 @@ class TestChannels(TestBase):
def test_base(self):
# creating channel yields a write and a read channal
wc, rc = mkchannel()
- assert isinstance(wc, Writer) # default args
- assert isinstance(rc, Reader)
+ assert isinstance(wc, ChannelWriter) # default args
+ assert isinstance(rc, ChannelReader)
# TEST UNLIMITED SIZE CHANNEL - writing+reading is FIFO
@@ -46,7 +46,7 @@ class TestChannels(TestBase):
# test callback channels
- wc, rc = mkchannel(wtype = CallbackWriter, rtype = CallbackReader)
+ wc, rc = mkchannel(wtype = CallbackChannelWriter, rtype = CallbackChannelReader)
cb = [0, 0] # set slots to one if called
def pre_write(item):
@@ -71,3 +71,17 @@ class TestChannels(TestBase):
assert rval == val + 1
+
+ # ITERATOR READER
+ reader = IteratorReader(iter(range(10)))
+ assert len(reader.read(2)) == 2
+ assert len(reader.read(0)) == 8
+ # its empty now
+ assert len(reader.read(0)) == 0
+ assert len(reader.read(5)) == 0
+
+ # doesn't work if item is not an iterator
+ self.failUnlessRaises(ValueError, IteratorReader, list())
+
+ # NOTE: its thread-safety is tested by the pool
+