From b72e2704022d889f116e49abf3e1e5d3e3192d3b Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 6 Jun 2010 01:00:12 +0200 Subject: Improved pool design and started rough implementation, top down to learn while going. Tests will be written soon for verification, its still quite theoretical --- test/git/async/test_channel.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'test/git/async/test_channel.py') diff --git a/test/git/async/test_channel.py b/test/git/async/test_channel.py index ad68a8d5..2a3c1585 100644 --- a/test/git/async/test_channel.py +++ b/test/git/async/test_channel.py @@ -20,12 +20,15 @@ class TestChannels(TestBase): item2 = 2 wc.write(item) wc.write(item2) - assert rc.read() == item - assert rc.read() == item2 + + # read all - it blocks as its still open for writing + st = time.time() + assert rc.read(timeout=1) == [item, item2] + assert time.time() - st >= 1.0 # next read blocks, then raises - it waits a second st = time.time() - self.failUnlessRaises(IOError, rc.read, True, 1) + assert len(rc.read(1, True, 1)) == 0 assert time.time() - st >= 1.0 # writing to a closed channel raises @@ -38,7 +41,7 @@ class TestChannels(TestBase): self.failUnlessRaises(IOError, wc.write, 1) # reading from a closed channel never blocks - self.failUnlessRaises(IOError, rc.read) + assert len(rc.read()) == 0 @@ -49,13 +52,16 @@ class TestChannels(TestBase): # blocks for a second, its full st = time.time() - self.failUnlessRaises(IOError, wc.write, item, True, 1) + self.failUnlessRaises(EOFError, wc.write, item, True, 1) assert time.time() - st >= 1.0 - # get one - assert rc.read() == item + # get our only one + assert rc.read(1)[0] == item # its empty,can put one again wc.write(item2) - assert rc.read() == item2 wc.close() + + # reading 10 will only yield one, it will not block as its closed + assert rc.read(10, timeout=1)[0] == item2 + -- cgit v1.2.1