<s> import six <EOL> import sys <EOL> import os <EOL> import errno <EOL> from gevent import select , socket <EOL> import greentest <EOL> import unittest <EOL> class TestSelect ( greentest . GenericWaitTestCase ) : <EOL> def wait ( self , timeout ) : <EOL> select . select ( [ ] , [ ] , [ ] , timeout ) <EOL> if sys . platform != '<STR_LIT:win32>' : <EOL> class TestSelectRead ( greentest . GenericWaitTestCase ) : <EOL> def wait ( self , timeout ) : <EOL> r , w = os . pipe ( ) <EOL> try : <EOL> select . select ( [ r ] , [ ] , [ ] , timeout ) <EOL> finally : <EOL> os . close ( r ) <EOL> os . close ( w ) <EOL> @ unittest . skipIf ( sys . platform . startswith ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def test_errno ( self ) : <EOL> with open ( __file__ , '<STR_LIT:rb>' ) as fp : <EOL> fd = fp . fileno ( ) <EOL> fp . close ( ) <EOL> try : <EOL> select . select ( [ fd ] , [ ] , [ ] , <NUM_LIT:0> ) <EOL> except OSError as err : <EOL> self . assertEqual ( err . errno , errno . EBADF ) <EOL> except select . error as err : <EOL> self . assertEqual ( err . args [ <NUM_LIT:0> ] , errno . EBADF ) <EOL> else : <EOL> self . fail ( "<STR_LIT>" ) <EOL> if hasattr ( select , '<STR_LIT>' ) : <EOL> class TestPollRead ( greentest . GenericWaitTestCase ) : <EOL> def wait ( self , timeout ) : <EOL> r , w = os . pipe ( ) <EOL> try : <EOL> poll = select . poll ( ) <EOL> poll . register ( r , select . POLLIN ) <EOL> poll . poll ( timeout * <NUM_LIT:1000> ) <EOL> finally : <EOL> poll . unregister ( r ) <EOL> os . close ( r ) <EOL> os . close ( w ) <EOL> def test_unregister_never_registered ( self ) : <EOL> poll = select . poll ( ) <EOL> self . assertRaises ( KeyError , poll . unregister , <NUM_LIT:5> ) <EOL> def test_poll_invalid ( self ) : <EOL> with open ( __file__ , '<STR_LIT:rb>' ) as fp : <EOL> fd = fp . fileno ( ) <EOL> fp . close ( ) <EOL> poll = select . poll ( ) <EOL> poll . register ( fd , select . POLLIN ) <EOL> result = poll . poll ( <NUM_LIT:0> ) <EOL> self . assertEqual ( result , [ ( fd , select . POLLNVAL ) ] ) <EOL> class TestSelectTypes ( greentest . TestCase ) : <EOL> def test_int ( self ) : <EOL> sock = socket . socket ( ) <EOL> select . select ( [ int ( sock . fileno ( ) ) ] , [ ] , [ ] , <NUM_LIT> ) <EOL> if hasattr ( six . builtins , '<STR_LIT>' ) : <EOL> def test_long ( self ) : <EOL> sock = socket . socket ( ) <EOL> select . select ( <EOL> [ six . builtins . long ( sock . fileno ( ) ) ] , [ ] , [ ] , <NUM_LIT> ) <EOL> def test_string ( self ) : <EOL> self . switch_expected = False <EOL> self . assertRaises ( TypeError , select . select , [ '<STR_LIT:hello>' ] , [ ] , [ ] , <NUM_LIT> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> greentest . main ( ) </s>
