Beispiel #1
0
    def test_io(self):
        if greentest.WIN:
            # libev raises IOError, libuv raises ValueError
            Error = (IOError, ValueError)
        else:
            Error = ValueError

        with self.assertRaises(Error):
            self.loop.io(-1, 1)

        if hasattr(core, 'TIMER'):
            # libev
            with self.assertRaises(ValueError):
                self.loop.io(1, core.TIMER)  # pylint:disable=no-member

        # Test we can set events and io before it's started
        if not greentest.WIN:
            # We can't do this with arbitrary FDs on windows;
            # see libev_vfd.h
            io = self.loop.io(1, core.READ)  # pylint:disable=no-member
            io.fd = 2
            self.assertEqual(io.fd, 2)
            io.events = core.WRITE  # pylint:disable=no-member
            if not hasattr(core, 'libuv'):
                # libev
                # pylint:disable=no-member
                self.assertEqual(core._events_to_str(io.events),
                                 'WRITE|_IOFDSET')
            else:

                self.assertEqual(
                    core._events_to_str(io.events),  # pylint:disable=no-member
                    'WRITE')
            io.start(lambda: None)
            io.close()
Beispiel #2
0
    def test_io(self):
        if sys.platform == 'win32':
            # libev raises IOError, libuv raises ValueError
            Error = (IOError, ValueError)
            win32 = True
        else:
            Error = ValueError
            win32 = False
        with self.assertRaises(Error):
            core.loop().io(-1, 1)
        if hasattr(core, 'TIMER'):
            # libev
            with self.assertRaises(ValueError):
                core.loop().io(1, core.TIMER)

        # Test we can set events and io before it's started
        if not win32:
            # We can't do this with arbitrary FDs on windows;
            # see libev_vfd.h
            io = core.loop().io(1, core.READ)
            io.fd = 2
            self.assertEqual(io.fd, 2)
            io.events = core.WRITE
            if not hasattr(core, 'libuv'):
                # libev
                self.assertEqual(core._events_to_str(io.events),
                                 'WRITE|_IOFDSET')
            else:
                self.assertEqual(core._events_to_str(io.events), 'WRITE')
            io.close()
Beispiel #3
0
 def test_io(self):
     if sys.platform == 'win32':
         Error = IOError
         win32 = True
     else:
         Error = ValueError
         win32 = False
     self.assertRaises(Error, core.loop().io, -1, 1)
     self.assertRaises(ValueError, core.loop().io, 1, core.TIMER)
     # Test we can set events and io before it's started
     if not win32:
         # We can't do this with arbitrary FDs on windows;
         # see libev_vfd.h
         io = core.loop().io(1, core.READ)
         io.fd = 2
         self.assertEqual(io.fd, 2)
         io.events = core.WRITE
         self.assertEqual(core._events_to_str(io.events), 'WRITE|_IOFDSET')
Beispiel #4
0
 def test_events_conversion(self):
     self.assertEqual(
         core._events_to_str(core.READ | core.WRITE),  # pylint: disable=no-member
         'READ|WRITE')
Beispiel #5
0
 def test_events_conversion(self):
     self.assertEqual(core._events_to_str(core.READ | core.WRITE), 'READ|WRITE')
Beispiel #6
0
 def test_events_conversion(self):
     self.assertEqual(core._events_to_str(core.READ | core.WRITE),
                      'READ|WRITE')