Beispiel #1
0
    def test_blocking_finite_fail(self):
        class TBI(Thread):
            def __init__(self, lsc):
                Thread.__init__(self)
                self.lsc = lsc

            def run(self):
                sleep(0.1)
                self.lsc._on_async_fail()

        lsc = LockSignalledChannel()
        lsc.blocking = True
        lsc.timeout = 1
        TBI(lsc).start()
        self.assertRaises(ChannelFailure, lsc.read, 4)        
Beispiel #2
0
    def test_blocking_finite_foreigndata_lessread(self):
        class TBI(Thread):
            def __init__(self, lsc):
                Thread.__init__(self)
                self.lsc = lsc

            def run(self):
                sleep(0.5)
                self.lsc._on_async_data('test')

        lsc = LockSignalledChannel()
        lsc.blocking = True
        lsc.timeout = 1
        TBI(lsc).start()
        self.assertEquals(lsc.read(100, less=True, peek=True), 'test')        
        self.assertEquals(lsc.read(100, less=True), 'test')        
Beispiel #3
0
    def test_blocking_finite_close(self):
        class TBI(Thread):
            def __init__(self, lsc):
                Thread.__init__(self)
                self.lsc = lsc

            def run(self):
                sleep(0.1)
                self.lsc._on_async_close()

        lsc = LockSignalledChannel()
        lsc.blocking = True
        lsc.timeout = 1
        TBI(lsc).start()
        self.assertRaises(ChannelClosed, lsc.read, 4, less=False, peek=True)
        self.assertRaises(ChannelClosed, lsc.read, 4)                
Beispiel #4
0
 def test_nonblocking_localdata_read(self):
     lsc = LockSignalledChannel()
     lsc._on_data('test')
     self.assertEquals(lsc.read(4, less=False, peek=True), 'test')
     self.assertEquals(lsc.read(4), 'test')
Beispiel #5
0
 def test_blocking_finite_null_read(self):
     lsc = LockSignalledChannel()
     lsc.blocking = True
     lsc.timeout = 1
     self.assertRaises(DataNotAvailable, lsc.read, 10, less=False, peek=True)
     self.assertRaises(DataNotAvailable, lsc.read, 10)