コード例 #1
0
 def test_parked_closed(self):
     ch = Channel()
     def closing():
         yield sleep(0.005)
         ch.close()
     go(closing)
     self.assertEqual((yield put(ch, 42)), False)
コード例 #2
0
 def test_immediate_puts_and_takes(self):
     ch = Channel(1)
     i = 0
     while i < self.limit:
         i += 1
         yield put(ch, 1)
         yield take(ch)
コード例 #3
0
 def test_parked_taken(self):
     ch = Channel()
     def taking():
         yield sleep(0.005)
         yield take(ch)
     go(taking)
     self.assertEqual((yield put(ch, 42)), True)
コード例 #4
0
 def test_no_priority(self):
     nums = range(50)
     chs = [Channel(1) for _ in nums]
     for i in nums:
         yield put(chs[i], i)
     values = []
     for _ in nums:
         values.append((yield alts(chs)).value)
     self.assertNotEqual(values, nums)
コード例 #5
0
 def test_default_value(self):
     ch = Channel(1)
     r = yield alts([ch], default=42)
     self.assertEqual(r.value, 42)
     self.assertEqual(r.channel, DEFAULT)
     yield put(ch, 53)
     r = yield alts([ch], default=42)
     self.assertEqual(r.value, 53)
     self.assertEqual(r.channel, ch)
コード例 #6
0
 def test_immediate_buffered(self):
     ch = Channel(1)
     yield put(ch, 42)
     self.assertEqual((yield take(ch)), 42)
コード例 #7
0
 def putting():
     yield put(ch, 42)
コード例 #8
0
 def test_immediate_closed(self):
     ch = Channel()
     ch.close()
     self.assertEqual((yield put(ch, 42)), False)
コード例 #9
0
 def test_immediate_buffered(self):
     ch = Channel(1)
     self.assertEqual((yield put(ch, 42)), True)
コード例 #10
0
 def test_putting_onto_closed_channel(self):
     i = 0
     while i < self.limit:
         i += 1
         yield put(self.ch, 42)
コード例 #11
0
 def test_immediate_taken(self):
     ch = Channel()
     def taking():
         yield take(ch)
     go(taking)
     self.assertEqual((yield put(ch, 42)), True)
コード例 #12
0
 def putting():
     yield sleep(0.005)
     yield put(ch, 42)