<s> import unittest <EOL> import time <EOL> import mock <EOL> from openhtf . util import timeouts <EOL> class TestUtil ( unittest . TestCase ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> cls . timeout = <NUM_LIT> <EOL> cls . polledtimeout = timeouts . PolledTimeout ( cls . timeout ) <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> pass <EOL> @ mock . patch . object ( time , '<STR_LIT:time>' ) <EOL> def test_timeExpired_false ( self , mock_time ) : <EOL> elapsed = <NUM_LIT:3> <EOL> mock_time . side_effect = [ <NUM_LIT:1> , <NUM_LIT:1> + elapsed , <NUM_LIT:2> + elapsed ] <EOL> self . polledtimeout . Restart ( ) <EOL> sec = self . polledtimeout . seconds <EOL> self . assertLessEqual ( sec , self . timeout - elapsed ) <EOL> self . assertFalse ( self . polledtimeout . HasExpired ( ) ) <EOL> def test_timeExpired_true ( self ) : <EOL> self . polledtimeout . Expire ( ) <EOL> self . assertTrue ( self . polledtimeout . HasExpired ( ) ) </s>
