<s> import unittest <EOL> from datetime import datetime , timedelta <EOL> from nose import SkipTest <EOL> try : <EOL> import gevent <EOL> except ImportError : <EOL> raise SkipTest ( "<STR_LIT>" ) <EOL> from rx . concurrency import GEventScheduler <EOL> class TestGEventScheduler ( unittest . TestCase ) : <EOL> def test_gevent_schedule_now ( self ) : <EOL> scheduler = GEventScheduler ( ) <EOL> res = scheduler . now ( ) - datetime . now ( ) <EOL> assert ( res < timedelta ( seconds = <NUM_LIT:1> ) ) <EOL> def test_gevent_schedule_action ( self ) : <EOL> scheduler = GEventScheduler ( ) <EOL> ran = [ False ] <EOL> def action ( scheduler , state ) : <EOL> ran [ <NUM_LIT:0> ] = True <EOL> scheduler . schedule ( action ) <EOL> gevent . sleep ( <NUM_LIT:0.1> ) <EOL> assert ( ran [ <NUM_LIT:0> ] == True ) <EOL> def test_gevent_schedule_action_due ( self ) : <EOL> scheduler = GEventScheduler ( ) <EOL> starttime = datetime . now ( ) <EOL> endtime = [ None ] <EOL> def action ( scheduler , state ) : <EOL> endtime [ <NUM_LIT:0> ] = datetime . now ( ) <EOL> scheduler . schedule_relative ( <NUM_LIT> , action ) <EOL> gevent . sleep ( <NUM_LIT> ) <EOL> diff = endtime [ <NUM_LIT:0> ] - starttime <EOL> assert ( diff > timedelta ( seconds = <NUM_LIT> ) ) <EOL> def test_gevent_schedule_action_cancel ( self ) : <EOL> scheduler = GEventScheduler ( ) <EOL> ran = [ False ] <EOL> def action ( scheduler , state ) : <EOL> ran [ <NUM_LIT:0> ] = True <EOL> d = scheduler . schedule_relative ( <NUM_LIT> , action ) <EOL> d . dispose ( ) <EOL> gevent . sleep ( <NUM_LIT:0.1> ) <EOL> assert ( not ran [ <NUM_LIT:0> ] ) </s>
