예제 #1
0
    def test_complete(self):
        ''' Make sure it works with both readable and writable streams '''
        poller = Poller(1)
        result = []

        #
        # Insert a number of streams, make all of them readable
        # and just a subset writable.  The partial overlap is to
        # make sure that readable, writable and read-writable
        # streams are all processed correctly.
        #
        for i in range(256):
            stream = TestCheckTimeoutStream(result, i)
            poller.readset[i] = stream
            if i > 14 and i < 128:
                poller.writeset[i] = stream

        # This should close odd streams only
        poller.check_timeout()

        # Check we have closed the right streams
        self.assertEqual(sorted(result), range(1, 256, 2))

        # Make sure the readable set is consistent
        self.assertEqual(sorted(poller.readset), range(0, 256, 2))

        # Make sure the writable set is consistent
        self.assertEqual(sorted(poller.writeset), range(16, 128, 2))
예제 #2
0
 def test_writable(self):
     ''' Make sure it runs when there's only writable stuff '''
     poller = Poller(1)
     result = []
     stream = TestCheckTimeoutStream(result, 1)
     poller.writeset[1] = stream
     poller.check_timeout()
     self.assertEqual(result, [1])
예제 #3
0
 def test_writable(self):
     ''' Make sure it runs when there's only writable stuff '''
     poller = Poller(1)
     result = []
     stream = TestCheckTimeoutStream(result, 1)
     poller.writeset[1] = stream
     poller.check_timeout()
     self.assertEqual(result, [1])
예제 #4
0
    def test_complete(self):
        ''' Make sure it works with both readable and writable streams '''
        poller = Poller(1)
        result = []

        #
        # Insert a number of streams, make all of them readable
        # and just a subset writable.  The partial overlap is to
        # make sure that readable, writable and read-writable
        # streams are all processed correctly.
        #
        for i in range(256):
            stream = TestCheckTimeoutStream(result, i)
            poller.readset[i] = stream
            if i > 14 and i < 128:
                poller.writeset[i] = stream

        # This should close odd streams only
        poller.check_timeout()

        # Check we have closed the right streams
        self.assertEqual(sorted(result), range(1, 256, 2))

        # Make sure the readable set is consistent
        self.assertEqual(sorted(poller.readset), range(0, 256, 2))

        # Make sure the writable set is consistent
        self.assertEqual(sorted(poller.writeset), range(16, 128, 2))