<s> from __future__ import print_function <EOL> import subprocess <EOL> import sys <EOL> from dccautomation import bootstrap , compat , utils <EOL> class BackendTests ( compat . unittest . TestCase ) : <EOL> def test_uninitialized_socket_behavior ( self ) : <EOL> s = compat . MQ . socket ( compat . MQ . REQ ) <EOL> self . assertRaises ( compat . MQ . errtype , s . recv ) <EOL> s . close ( ) <EOL> s = compat . MQ . socket ( compat . MQ . REP ) <EOL> self . assertRaises ( compat . MQ . errtype , s . send , b'<STR_LIT:1>' ) <EOL> s . close ( ) <EOL> def test_invalid_socket_type ( self ) : <EOL> self . assertRaises ( ValueError , compat . MQ . socket , - <NUM_LIT> ) <EOL> def test_rebind_fails ( self ) : <EOL> if not compat . MQ . safe_to_rebind ( ) : <EOL> raise compat . unittest . SkipTest ( '<STR_LIT>' ) <EOL> s1 = utils . create_rep_socket_bound_to_random ( ) <EOL> s2 = compat . MQ . socket ( compat . MQ . REP ) <EOL> self . assertRaises ( compat . MQ . errtype , s2 . bind , s1 . endpoint ) <EOL> def test_bound_socket_is_cleaned_up_in_subproc ( self ) : <EOL> """<STR_LIT>""" <EOL> args = [ <EOL> sys . executable , <EOL> '<STR_LIT:-c>' , <EOL> '<STR_LIT>' ] <EOL> p = bootstrap . start_process ( <EOL> args , stdout = subprocess . PIPE ) <EOL> endpoint = p . stdout . readline ( ) . strip ( ) . decode ( '<STR_LIT:utf-8>' ) <EOL> p . kill ( ) <EOL> p . wait ( ) <EOL> self . assertTrue ( p . returncode ) <EOL> s = compat . MQ . socket ( compat . MQ . REP ) <EOL> s . bind ( endpoint ) <EOL> def bind_and_wait ( ) : <EOL> s = utils . create_rep_socket_bound_to_random ( ) <EOL> print ( s . endpoint ) <EOL> while True : <EOL> print ( '<STR_LIT>' ) <EOL> class CalcBackendTests ( compat . unittest . TestCase ) : <EOL> def test_unknown ( self ) : <EOL> self . assertRaises ( ValueError , compat . calc_backend , '<STR_LIT>' ) <EOL> def test_no_matching ( self ) : <EOL> def f ( ) : <EOL> raise ImportError ( ) <EOL> compat . _fakebackend = f <EOL> with self . assertRaises ( ImportError ) : <EOL> compat . calc_backend ( '<STR_LIT>' , [ '<STR_LIT>' ] ) </s>
