<s> import unittest2 as unittest <EOL> from mox3 . mox import MoxTestBase , IsA <EOL> from gevent . lock import Semaphore <EOL> from slimta . util . deque import BlockingDeque <EOL> class TestBlockingDeque ( unittest . TestCase , MoxTestBase ) : <EOL> def setUp ( self ) : <EOL> super ( TestBlockingDeque , self ) . setUp ( ) <EOL> self . deque = BlockingDeque ( ) <EOL> self . deque . sema = self . mox . CreateMock ( Semaphore ) <EOL> def test_append ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . append ( True ) <EOL> def test_appendleft ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . appendleft ( True ) <EOL> def test_clear ( self ) : <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> self . deque . sema . release ( ) <EOL> for i in range ( <NUM_LIT:3> ) : <EOL> self . deque . sema . locked ( ) . AndReturn ( False ) <EOL> self . deque . sema . acquire ( blocking = False ) <EOL> self . deque . sema . locked ( ) . AndReturn ( True ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . append ( True ) <EOL> self . deque . append ( True ) <EOL> self . deque . append ( True ) <EOL> self . deque . clear ( ) <EOL> def test_extend ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . extend ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> def test_extendleft ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . extendleft ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> def test_pop ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . acquire ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . append ( <NUM_LIT:4> ) <EOL> self . deque . append ( <NUM_LIT:5> ) <EOL> self . assertEqual ( <NUM_LIT:5> , self . deque . pop ( ) ) <EOL> def test_popleft ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . acquire ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . append ( <NUM_LIT:4> ) <EOL> self . deque . append ( <NUM_LIT:5> ) <EOL> self . assertEqual ( <NUM_LIT:4> , self . deque . popleft ( ) ) <EOL> def test_remove ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . acquire ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . append ( <NUM_LIT:4> ) <EOL> self . deque . append ( <NUM_LIT:5> ) <EOL> self . deque . remove ( <NUM_LIT:4> ) <EOL> def test_remove_notfound ( self ) : <EOL> self . deque . sema . release ( ) <EOL> self . deque . sema . release ( ) <EOL> self . mox . ReplayAll ( ) <EOL> self . deque . append ( <NUM_LIT:4> ) <EOL> self . deque . append ( <NUM_LIT:5> ) <EOL> with self . assertRaises ( ValueError ) : <EOL> self . deque . remove ( <NUM_LIT:6> ) </s>
